home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Graphics / Plotting / GnuTerm_1.1a / Source / term.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-19  |  72.5 KB  |  2,380 lines

  1. #ifndef lint
  2. static char *RCSid = "$Id: term.c,v 1.66 1995/06/16 12:35:53 drd Exp $";
  3. #endif
  4.  
  5.  
  6. /* GNUPLOT - term.c */
  7. /*
  8.  * Copyright (C) 1986 - 1993   Thomas Williams, Colin Kelley
  9.  *
  10.  * Permission to use, copy, and distribute this software and its
  11.  * documentation for any purpose with or without fee is hereby granted, 
  12.  * provided that the above copyright notice appear in all copies and 
  13.  * that both that copyright notice and this permission notice appear 
  14.  * in supporting documentation.
  15.  *
  16.  * Permission to modify the software is granted, but not the right to
  17.  * distribute the modified code.  Modifications are to be distributed 
  18.  * as patches to released version.
  19.  *  
  20.  * This software is provided "as is" without express or implied warranty.
  21.  *
  22.  *
  23.  * AUTHORS
  24.  * 
  25.  *   Original Software:
  26.  *     Thomas Williams,  Colin Kelley.
  27.  * 
  28.  *   Gnuplot 2.0 additions:
  29.  *       Russell Lang, Dave Kotz, John Campbell.
  30.  *
  31.  *   Gnuplot 3.0 additions:
  32.  *       Gershon Elber and many others.
  33.  * 
  34.  * There is a mailing list for gnuplot users. Note, however, that the
  35.  * newsgroup 
  36.  *    comp.graphics.gnuplot 
  37.  * is identical to the mailing list (they
  38.  * both carry the same set of messages). We prefer that you read the
  39.  * messages through that newsgroup, to subscribing to the mailing list.
  40.  * (If you can read that newsgroup, and are already on the mailing list,
  41.  * please send a message info-gnuplot-request@dartmouth.edu, asking to be
  42.  * removed from the mailing list.)
  43.  *
  44.  * The address for mailing to list members is
  45.  *       info-gnuplot@dartmouth.edu
  46.  * and for mailing administrative requests is 
  47.  *       info-gnuplot-request@dartmouth.edu
  48.  * The mailing list for bug reports is 
  49.  *       bug-gnuplot@dartmouth.edu
  50.  * The list of those interested in beta-test versions is
  51.  *       info-gnuplot-beta@dartmouth.edu
  52.  */
  53.  
  54. #include <ctype.h>
  55. #include <math.h>
  56. #ifdef ONEXT
  57. #include "epsviewe.h"
  58. #endif /* ONEXT */
  59. #include "driver.h" /* gets plot.h, setshow.h, bitmap.h */
  60.  
  61. #ifdef OLD_TERMINALS
  62. #include "term.h"
  63. #endif
  64.  
  65. #ifdef _Windows
  66. #ifdef __MSC__
  67. #include <malloc.h>
  68. #else
  69. #include <alloc.h>
  70. #endif
  71. #endif
  72.  
  73. #ifdef vms
  74. /* for a quiet life */
  75. extern sys$crembx();
  76. extern sys$assign();
  77. extern sys$dassgn();
  78. extern sys$qio();
  79. extern sys$qiow();
  80. extern lib$signal();
  81. extern lib$spawn();
  82. #endif
  83.  
  84. /* for use by all drivers */
  85. #define sign(x) ((x) >= 0 ? 1 : -1)
  86.  
  87. /* I'd rather this was ABS(x), but dont fancy going through all the terms */
  88. #ifdef abs /* SAS/C and DECC/AXP-VMS have abs() as a macro */
  89. #undef abs
  90. #endif
  91. #define abs(x) ((x) >= 0 ? (x) : -(x))
  92.  
  93.  
  94. #ifndef max    /* GCC uses inline functions */
  95. #define max(a,b) ((a) > (b) ? (a) : (b))
  96. #endif
  97. #ifndef min
  98. #define min(a,b) ((a) < (b) ? (a) : (b))
  99. #endif
  100.  
  101. TBOOLEAN term_init;            /* true if terminal has been initialized */
  102. TBOOLEAN term_graphics=FALSE;    /* true if terminal is in graphics mode */
  103. TBOOLEAN term_suspended=FALSE;   /* we have suspended the driver, in multiplot mode */
  104. extern FILE *outfile;
  105. extern char outstr[];
  106. extern float xsize, ysize;
  107.  
  108. void do_point __P((unsigned int x, unsigned int y, int number));
  109. void line_and_point __P((unsigned int x, unsigned int y, int number));
  110. void do_arrow __P((unsigned int sx, unsigned int sy, unsigned int ex, unsigned int ey, int head));
  111. int null_text_angle __P((int ang));
  112. int null_justify_text __P((enum JUSTIFY just));
  113. int null_scale __P((double x, double y));
  114. int do_scale __P((double x, double y));
  115. void options_null __P((void));
  116. void UNKNOWN_null __P((void));
  117.  
  118. #ifdef __ZTC__
  119. char *ztc_init();
  120. /* #undef TGIF */
  121. #endif
  122.  
  123. #if defined(MSDOS)||defined(ATARI)||defined(MTOS)||defined(OS2)||defined(_Windows)||defined(DOS386)
  124. void reopen_binary();
  125. #define REOPEN_BINARY
  126. #endif
  127. #ifdef vms
  128. char *vms_init();
  129. void vms_reset();
  130. void term_mode_tek();
  131. void term_mode_native();
  132. void term_pasthru();
  133. void term_nopasthru();
  134. void reopen_binary();
  135. void fflush_binary();
  136. #define REOPEN_BINARY
  137. #endif
  138.  
  139. /* This is needed because the unixplot library only writes to stdout. */
  140. #ifdef UNIXPLOT
  141. FILE save_stdout;
  142. #endif
  143. int unixplot=0;
  144.  
  145. #if defined(MTOS) || defined(ATARI)
  146. int aesid = -1;
  147. #endif
  148.  
  149. #define NICE_LINE        0
  150. #define POINT_TYPES        6
  151.  
  152.  
  153. void do_point(x,y,number)
  154. unsigned int x,y;
  155. int number;
  156. {
  157. register int htic,vtic;
  158. register struct termentry *t = term;
  159.  
  160.      if (number < 0) {        /* do dot */
  161.         (*t->move)(x,y);
  162.         (*t->vector)(x,y);
  163.         return;
  164.     }
  165.  
  166.     number %= POINT_TYPES;
  167.     htic = (pointsize*t->h_tic/2);    /* should be in term_tbl[] in later version */
  168.     vtic = (pointsize*t->v_tic/2);    
  169.  
  170.     switch(number) {
  171.         case 0: /* do diamond */ 
  172.                 (*t->move)(x-htic,y);
  173.                 (*t->vector)(x,y-vtic);
  174.                 (*t->vector)(x+htic,y);
  175.                 (*t->vector)(x,y+vtic);
  176.                 (*t->vector)(x-htic,y);
  177.                 (*t->move)(x,y);
  178.                 (*t->vector)(x,y);
  179.                 break;
  180.         case 1: /* do plus */ 
  181.                 (*t->move)(x-htic,y);
  182.                 (*t->vector)(x-htic,y);
  183.                 (*t->vector)(x+htic,y);
  184.                 (*t->move)(x,y-vtic);
  185.                 (*t->vector)(x,y-vtic);
  186.                 (*t->vector)(x,y+vtic);
  187.                 break;
  188.         case 2: /* do box */ 
  189.                 (*t->move)(x-htic,y-vtic);
  190.                 (*t->vector)(x-htic,y-vtic);
  191.                 (*t->vector)(x+htic,y-vtic);
  192.                 (*t->vector)(x+htic,y+vtic);
  193.                 (*t->vector)(x-htic,y+vtic);
  194.                 (*t->vector)(x-htic,y-vtic);
  195.                 (*t->move)(x,y);
  196.                 (*t->vector)(x,y);
  197.                 break;
  198.         case 3: /* do X */ 
  199.                 (*t->move)(x-htic,y-vtic);
  200.                 (*t->vector)(x-htic,y-vtic);
  201.                 (*t->vector)(x+htic,y+vtic);
  202.                 (*t->move)(x-htic,y+vtic);
  203.                 (*t->vector)(x-htic,y+vtic);
  204.                 (*t->vector)(x+htic,y-vtic);
  205.                 break;
  206.         case 4: /* do triangle */ 
  207.                 (*t->move)(x,y+(4*vtic/3));
  208.                 (*t->vector)(x-(4*htic/3),y-(2*vtic/3));
  209.                 (*t->vector)(x+(4*htic/3),y-(2*vtic/3));
  210.                 (*t->vector)(x,y+(4*vtic/3));
  211.                 (*t->move)(x,y);
  212.                 (*t->vector)(x,y);
  213.                 break;
  214.         case 5: /* do star */ 
  215.                 (*t->move)(x-htic,y);
  216.                 (*t->vector)(x-htic,y);
  217.                 (*t->vector)(x+htic,y);
  218.                 (*t->move)(x,y-vtic);
  219.                 (*t->vector)(x,y-vtic);
  220.                 (*t->vector)(x,y+vtic);
  221.                 (*t->move)(x-htic,y-vtic);
  222.                 (*t->vector)(x-htic,y-vtic);
  223.                 (*t->vector)(x+htic,y+vtic);
  224.                 (*t->move)(x-htic,y+vtic);
  225.                 (*t->vector)(x-htic,y+vtic);
  226.                 (*t->vector)(x+htic,y-vtic);
  227.                 break;
  228.     }
  229. }
  230.  
  231.  
  232. /*
  233.  * general point routine
  234.  */
  235. void line_and_point(x,y,number)
  236. unsigned int x,y;
  237. int number;
  238. {
  239.     /* temporary(?) kludge to allow terminals with bad linetypes 
  240.         to make nice marks */
  241.  
  242.     (*term->linetype)(NICE_LINE);
  243.     do_point(x,y,number);
  244. }
  245.  
  246. /* 
  247.  * general arrow routine
  248.  *
  249.  * I set the angle between the arrowhead and the line 15 degree.
  250.  * The length of arrowhead varies depending on the line length 
  251.  * within the the range [0.3*(the-tic-length), 2*(the-tic-length)].
  252.  * No head is printed if the arrow length is zero.
  253.  *
  254.  *            Yasu-hiro Yamazaki(hiro@rainbow.physics.utoronto.ca)
  255.  *            Jul 1, 1993
  256.  */
  257.  
  258. #define COS15 (0.96593)         /* cos of 15 degree */
  259. #define SIN15 (0.25882)         /* sin of 15 degree */
  260.  
  261. #define HEAD_LONG_LIMIT  (2.0)  /* long  limit of arrowhead length */
  262. #define HEAD_SHORT_LIMIT (0.3)  /* short limit of arrowhead length */
  263.                                 /* their units are the "tic" length */ 
  264.  
  265. #define HEAD_COEFF  (0.3)       /* default value of head/line length ratio */
  266.  
  267. void do_arrow(sx, sy, ex, ey, head)
  268.     unsigned int sx,sy;            /* start point */
  269.     unsigned int ex, ey;            /* end point (point of arrowhead) */
  270.     TBOOLEAN head;
  271. {
  272.     register struct termentry *t = term;
  273.     float len_tic = ((double) (t->h_tic + t->v_tic) )/2.0;
  274.                                        /* average of tic sizes */
  275.     double dx = (double)sx - (double)ex;
  276.     double dy = (double)sy - (double)ey;     /* (dx,dy) : vector from end to start */
  277.     double len_arrow = sqrt( dx*dx + dy*dy );
  278.  
  279.     /* draw the line for the arrow. That's easy. */
  280.     (*t->move)(sx, sy);
  281.     (*t->vector)(ex, ey);
  282.  
  283.     if (head && len_arrow != 0.0) { /* no head for arrows whih length=0 */
  284.       /* now calc the head_coeff */
  285.       double  coeff_shortest = len_tic*HEAD_SHORT_LIMIT/len_arrow;
  286.       double  coeff_longest  = len_tic*HEAD_LONG_LIMIT/len_arrow;
  287.       double  head_coeff = max( coeff_shortest, 
  288.                                 min( HEAD_COEFF, coeff_longest) );
  289.     /* now draw the arrow head. */
  290.     /* we put the arrowhead marks at 15 degrees to line */
  291.       int x,y;            /* one endpoint */
  292.  
  293.       x = (int)( ex + ( COS15*dx - SIN15*dy) * head_coeff );
  294.       y = (int)( ey + ( SIN15*dx + COS15*dy) * head_coeff );
  295.       (*t->move)(x,y);
  296.       (*t->vector)(ex,ey);
  297.  
  298.       x = (int)( ex + ( COS15*dx + SIN15*dy) * head_coeff );
  299.       y = (int)( ey + (-SIN15*dx + COS15*dy) * head_coeff );
  300.      (*t->vector)(x,y);
  301.     }
  302. }
  303.  
  304. /* oiginal routine */
  305. #define ROOT2 (1.41421)        /* sqrt of 2 */
  306.  
  307. static void org_do_arrow(sx, sy, ex, ey, head)
  308.     int sx,sy;            /* start point */
  309.     int ex, ey;            /* end point (point of arrowhead) */
  310.     TBOOLEAN head;
  311. {
  312.     register struct termentry *t = term;
  313.     int len = (t->h_tic + t->v_tic)/2; /* arrowhead size = avg of tic sizes */
  314.  
  315.     /* draw the line for the arrow. That's easy. */
  316.     (*t->move)(sx, sy);
  317.     (*t->vector)(ex, ey);
  318.  
  319.     if (head) {
  320.     /* now draw the arrow head. */
  321.     /* we put the arrowhead marks at 45 degrees to line */
  322.        if (sx == ex) {
  323.        /* vertical line, special case */
  324.           int delta = ((float)len / ROOT2 + 0.5);
  325.           if (sy < ey)
  326.               delta = -delta;    /* up arrow goes the other way */
  327.           (*t->move)(ex - delta, ey + delta);
  328.           (*t->vector)(ex,ey);
  329.           (*t->vector)(ex + delta, ey + delta);
  330.        } else {
  331.           int dx = sx - ex;
  332.           int dy = sy - ey;
  333.           double coeff = len / sqrt(2.0*((double)dx*(double)dx 
  334.                    + (double)dy*(double)dy));
  335.           int x,y;            /* one endpoint */
  336.  
  337.           x = (int)( ex + (dx + dy) * coeff );
  338.           y = (int)( ey + (dy - dx) * coeff );
  339.           (*t->move)(x,y);
  340.           (*t->vector)(ex,ey);
  341.  
  342.           x = (int)( ex + (dx - dy) * coeff );
  343.           y = (int)( ey + (dy + dx) * coeff );
  344.           (*t->vector)(x,y);
  345.        }
  346.     }
  347. }
  348.  
  349. #if !defined(OLD_TERMINALS)
  350.  
  351. #define TERM_PROTO
  352. #define TERM_BODY
  353. #define TERM_PUBLIC static
  354.  
  355. #include "term.h"
  356.  
  357. #undef TERM_PROTO
  358. #undef TERM_BODY
  359. #undef TERM_PUBLIC
  360.  
  361. #else /* OLD_TERMINALS */
  362.  
  363. /* temporary defines for new terminal file format */
  364.  
  365. #define TERM_PROTO
  366. #define TERM_BODY
  367. #define TERM_PUBLIC static
  368.  
  369. #ifdef DUMB                    /* paper or glass dumb terminal */
  370. #include "term/dumb.trm"
  371. #endif
  372.  
  373.  
  374. #ifndef _Windows
  375. # ifdef PC            /* all PC types except MS WINDOWS*/
  376. #  include "term/pc.trm"
  377. # endif
  378. #else
  379. #  include "term/win.trm"
  380. #endif
  381.  
  382. #ifdef __ZTC__
  383. #include "term/fg.trm"
  384. #endif
  385.  
  386. #ifdef DJSVGA
  387. #include "term/djsvga.trm"    /* DJGPP SVGA */
  388. #endif
  389.  
  390. #ifdef EMXVGA
  391. #include "term/emxvga.trm"    /* EMX VGA */
  392. #endif
  393.  
  394. #ifdef OS2PM                    /* os/2 presentation manager */
  395. #include "term/pm.trm"
  396. #endif
  397.  
  398. #if defined(ATARI) || defined(MTOS)    /* ATARI-ST */
  399. #include "term/atarivdi.trm"
  400. #ifdef MTOS
  401. #include "term/multitos.trm"
  402. #endif
  403. #include "term/atariaes.trm"
  404. #endif
  405.  
  406. /*
  407.    all TEK types (TEK,BITGRAPH,KERMIT,VTTEK,SELANAR) are ifdef'd in tek.trm,
  408.    but most require various TEK routines.  Hence TEK must be defined for
  409.    the others to compile.
  410. */
  411. #ifdef BITGRAPH
  412. # ifndef TEK
  413. #  define TEK
  414. # endif
  415. #endif
  416.  
  417. #ifdef SELENAR
  418. # ifndef TEK
  419. #  define TEK
  420. # endif
  421. #endif
  422.  
  423. #ifdef KERMIT
  424. # ifndef TEK
  425. #  define TEK
  426. # endif
  427. #endif
  428.  
  429. #ifdef LN03P
  430. # ifndef TEK
  431. #  define TEK
  432. # endif
  433. #endif
  434.  
  435. #ifdef VTTEK
  436. # ifndef TEK
  437. #  define TEK
  438. # endif
  439. #endif
  440.  
  441. #ifdef T410X        /* Tektronix 4106, 4107, 4109 and 420x terminals */
  442. #include "term/t410x.trm"
  443. #endif
  444.  
  445. #ifdef TEK            /* all TEK types, TEK, BBN, SELANAR, KERMIT, VTTEK */
  446. #include "term/tek.trm"
  447. #endif
  448.  
  449. #ifdef OKIDATA
  450. #define EPSONP
  451. #endif
  452.  
  453. #ifdef EPSONP    /* bit map types, EPSON, NEC, PROPRINTER, STAR Color */
  454. #include "term/epson.trm"
  455. #endif
  456.  
  457. #ifdef HP500C  /* HP 500 deskjet Colour */
  458. #include "term/hp500c.trm"
  459. #endif
  460.  
  461. #ifdef HPLJII        /* HP LaserJet II */
  462. #include "term/hpljii.trm"
  463. #endif
  464.  
  465. #ifdef PCL /* HP LaserJet III in HPGL mode */
  466. #  ifndef HPGL
  467. #    define HPGL
  468. #  endif
  469. #endif
  470.  
  471. #ifdef HPPJ        /* HP PaintJet */
  472. #include "term/hppj.trm"
  473. #endif
  474.  
  475. #ifdef FIG            /* Fig 3.1 Interactive graphics program */
  476. #include "term/fig.trm"
  477. #include "term/bigfig.trm"
  478. #endif
  479.   
  480. #ifdef GPR              /* Apollo Graphics Primitive Resource (fixed-size window) */
  481. #include "term/gpr.trm"
  482. #endif /* GPR */
  483.  
  484. #ifdef APOLLO           /* Apollo Graphics Primitive Resource (resizable window) */
  485. #include "term/apollo.trm"
  486. #endif /* APOLLO */
  487.  
  488. #ifdef IMAGEN        /* IMAGEN printer */
  489. #include "term/imagen.trm"
  490. #endif
  491.  
  492. #ifdef MIF            /* Framemaker MIF  driver */
  493. #include "term/mif.trm"
  494. #endif
  495.  
  496. #ifdef MF            /* METAFONT driver */
  497. #include "term/metafont.trm"
  498. #endif
  499.  
  500. #ifdef TEXDRAW
  501. #include "term/texdraw.trm"
  502. #endif
  503.  
  504. #ifdef EEPIC        /* EEPIC (LATEX) type */
  505. #include "term/eepic.trm"
  506. # ifndef LATEX
  507. #  define LATEX
  508. # endif
  509. #endif
  510.  
  511. #ifdef EMTEX        /* EMTEX (LATEX for PC) type */
  512. # ifndef LATEX
  513. #  define LATEX
  514. # endif
  515. #endif
  516.  
  517. #ifdef LATEX        /* LATEX type */
  518. #include "term/latex.trm"
  519. #endif
  520.  
  521. #ifdef GPIC        /* GPIC (groff) type */ 
  522. #include "term/gpic.trm"
  523. #endif
  524.  
  525. #ifdef PBM        /* PBMPLUS portable bitmap */
  526. #include "term/pbm.trm"
  527. #endif
  528.  
  529. #ifdef POSTSCRIPT    /* POSTSCRIPT type */
  530. #include "term/post.trm"
  531. /*#include "term/enhpost.trm"*/
  532. #endif
  533.  
  534. #ifdef GRASS              /* GRASS (geographic info system) monitor */
  535. #include "term/grass.trm"
  536. #endif /* GRASS */
  537.  
  538. #ifdef PRESCRIBE    /* PRESCRIBE type */
  539. #include "term/kyo.trm"
  540. #endif
  541.  
  542. /* note: this must come after term/post.trm */
  543. #ifdef PSLATEX        /* LaTeX with embedded PostScript */
  544. #include "term/pslatex.trm"
  545. #endif
  546.  
  547. /* note: this must come after term/pslatex.trm */
  548. #ifdef PSTEX        /* Generic TeX with embedded PostScript */
  549. #include "term/pstex.trm"
  550. #endif
  551.  
  552. #ifdef PSTRICKS
  553. #include "term/pstricks.trm"
  554. #endif
  555.  
  556. #ifdef TPIC        /* TPIC (LATEX) type */
  557. #include "term/tpic.trm"
  558. # ifndef LATEX
  559. #  define LATEX
  560. # endif
  561. #endif
  562.  
  563. #ifdef UNIXPC     /* unix-PC  ATT 7300 or 3b1 machine */
  564. #include "term/unixpc.trm"
  565. #endif /* UNIXPC */
  566.  
  567. #ifdef AED
  568. #include "term/aed.trm"
  569. #endif /* AED */
  570.  
  571. #ifdef AIFM
  572. #include "term/ai.trm"
  573. #endif /* AIFM */
  574.  
  575. #ifdef COREL
  576. #include "term/corel.trm"
  577. #endif /* COREL */
  578.  
  579. #ifdef CGI
  580. #include "term/cgi.trm"
  581. #endif /* CGI */
  582.  
  583. #ifdef DEBUG
  584. #include "term/debug.trm"
  585. #endif /* DEBUG */
  586.  
  587. #ifdef EXCL
  588. #include "term/excl.trm"
  589. #endif /* EXCL */
  590.  
  591. #ifdef HP2648
  592. /* also works for HP2647 */
  593. #include "term/hp2648.trm"
  594. #endif /* HP2648 */
  595.  
  596. #ifdef HP26
  597. #include "term/hp26.trm"
  598. #endif /* HP26 */
  599.  
  600. #ifdef HP75
  601. #ifndef HPGL
  602. #define HPGL
  603. #endif
  604. #endif
  605.  
  606. #ifdef HP7550
  607. #ifndef HPGL
  608. #define HPGL
  609. #endif
  610. #endif
  611.  
  612. /* HPGL - includes HP75, HP7550 and HPLJIII in HPGL mode */
  613. #ifdef HPGL
  614. #include "term/hpgl.trm"
  615. #endif /* HPGL */
  616.  
  617. /* Roland DXY800A plotter driver by Martin Yii, eln557h@monu3.OZ 
  618.     and Russell Lang, rjl@monu1.cc.monash.oz */
  619. #ifdef DXY800A
  620. #include "term/dxy.trm"
  621. #endif /* DXY800A */
  622.  
  623. #ifdef GIF
  624. #include "term/gdgif.trm"
  625. #endif /* GIF */
  626.  
  627.  
  628. #ifdef IRIS4D
  629. #include "term/iris4d.trm"
  630. #endif /* IRIS4D */
  631.  
  632. #ifdef ONEXT
  633. #include "term/onext.trm"
  634. #endif /* ONEXT */
  635.  
  636. #ifdef NEXT
  637. #include "term/next.trm"
  638. #endif /* NEXT */
  639.  
  640. #ifdef QMS
  641. #include "term/qms.trm"
  642. #endif /* QMS */
  643.  
  644. #ifdef REGIS
  645. #include "term/regis.trm"
  646. #endif /* REGIS */
  647.  
  648. #ifdef RGIP
  649. #include "term/rgip.trm"
  650. #endif /* RGIP UNIPLEX */
  651.  
  652. #ifdef MGR
  653. #include "term/mgr.trm"
  654. #endif /* MGR */
  655.  
  656. #ifdef SUN
  657. #include "term/sun.trm"
  658. #endif /* SUN */
  659.  
  660. #ifdef VWS
  661. #include "term/vws.trm"
  662. #endif /* VWS */
  663.  
  664. #ifdef V384
  665. #include "term/v384.trm"
  666. #endif /* V384 */
  667.  
  668. #ifdef TGIF
  669. #include "term/tgif.trm"
  670. #endif /* TGIF */
  671.  
  672. #ifdef UNIXPLOT
  673. #ifdef GNUGRAPH
  674. #include "term/gnugraph.trm"
  675. #else
  676. #include "term/unixplot.trm"
  677. #endif /* GNUGRAPH */
  678. #endif /* UNIXPLOT */
  679.  
  680. #ifdef X11
  681. #include "term/x11.trm"
  682. #include "term/xlib.trm"
  683. #endif /* X11 */
  684.  
  685. #ifdef LINUX
  686. #include "term/linux.trm"
  687. #endif 
  688.  
  689. #ifdef DXF
  690. #include "term/dxf.trm"
  691. #endif /* DXF */
  692.   
  693. #ifdef AMIGASCREEN
  694. #include "term/amiga.trm"
  695. #endif /* AMIGASCREEN */
  696.  
  697. #undef TERM_PROTO
  698. #undef TERM_BODY
  699.  
  700. #endif /* OLD_TERMINALS */
  701.  
  702.  
  703. /* Dummy functions for unavailable features */
  704. /* return success if they asked for default - this simplifies code
  705.  * where param is passed as a param. Client can first pass it here,
  706.  * and only if it fails do they have to see what was trying to be done
  707.  */
  708.  
  709. /* change angle of text.  0 is horizontal left to right.
  710. * 1 is vertical bottom to top (90 deg rotate)  
  711. */
  712. int null_text_angle(ang)
  713. int ang;
  714. {
  715. return (ang==0);
  716. }
  717.  
  718. /* change justification of text.  
  719.  * modes are LEFT (flush left), CENTRE (centred), RIGHT (flush right)
  720.  */
  721. int null_justify_text(just)
  722. enum JUSTIFY just;
  723. {
  724. return (just==LEFT);
  725. }
  726.  
  727.  
  728. /* Change scale of plot.
  729.  * Parameters are x,y scaling factors for this plot.
  730.  * Some terminals (eg latex) need to do scaling themselves.
  731.  */
  732. int null_scale(x,y)
  733. double x;
  734. double y;
  735. {
  736. return FALSE ;    /* can't be done */
  737. }
  738.  
  739. int do_scale(x,y)
  740. double x;
  741. double y;
  742. {
  743. return TRUE ;    /* can be done */
  744. }
  745.  
  746. void options_null()
  747. {
  748.     term_options[0] = '\0';    /* we have no options */
  749. }
  750.  
  751. void UNKNOWN_null()
  752. {
  753. }
  754.  
  755. int set_font_null(s)
  756. char *s;
  757. {
  758.   return FALSE;
  759. }
  760.  
  761. void null_set_pointsize(s)
  762. double s;
  763. {
  764. }
  765.  
  766. /* cast to get rid of useless warnings about UNKNOWN_null */
  767. typedef void (*void_fp)();
  768.  
  769.  
  770. /* temporary macro to allow use of new terminal drivers */
  771. #define TERM_TABLE
  772. #define TERM_TABLE_START(x) ,{
  773. #define TERM_TABLE_END(x)   }
  774.  
  775.  
  776. /*
  777.  * term_tbl[] contains an entry for each terminal.  "unknown" must be the
  778.  *   first, since term is initialized to 0.
  779.  */
  780. struct termentry term_tbl[] = {
  781.     {"unknown", "Unknown terminal type - not a plotting device",
  782.       100, 100, 1, 1,
  783.       1, 1, options_null, UNKNOWN_null, UNKNOWN_null, 
  784.       UNKNOWN_null, null_scale, UNKNOWN_null, (void_fp)UNKNOWN_null, (void_fp)UNKNOWN_null, 
  785.       (void_fp)UNKNOWN_null, (void_fp)UNKNOWN_null, null_text_angle, 
  786.       null_justify_text, (void_fp)UNKNOWN_null, (void_fp)UNKNOWN_null, set_font_null}
  787.  
  788.     ,{"table", "Dump ASCII table of X Y [Z] values to output",
  789.       100, 100, 1, 1,
  790.       1, 1, options_null, UNKNOWN_null, UNKNOWN_null, 
  791.       UNKNOWN_null, null_scale, UNKNOWN_null, (void_fp)UNKNOWN_null, (void_fp)UNKNOWN_null, 
  792.       (void_fp)UNKNOWN_null, (void_fp)UNKNOWN_null, null_text_angle, 
  793.       null_justify_text, (void_fp)UNKNOWN_null, (void_fp)UNKNOWN_null, set_font_null}
  794.  
  795.  
  796. #if !defined(OLD_TERMINALS)
  797.  
  798. #include "term.h"
  799.  
  800. #else /* OLD_TERMINALS */
  801.  
  802. #ifdef AMIGASCREEN
  803.     ,{"amiga", "Amiga Custom Screen",
  804.        AMIGA_XMAX, AMIGA_YMAX, AMIGA_VCHAR, AMIGA_HCHAR, 
  805.        AMIGA_VTIC, AMIGA_HTIC, options_null, AMIGA_init, AMIGA_reset, 
  806.        AMIGA_text, null_scale, AMIGA_graphics, AMIGA_move, AMIGA_vector,
  807.        AMIGA_linetype, AMIGA_put_text, null_text_angle, 
  808.        AMIGA_justify_text, do_point, do_arrow, set_font_null}
  809. #endif
  810.  
  811. #ifdef MTOS
  812.     ,{"mtos", "Atari MiNT/MULTITOS/Magic Terminal",
  813.        MTOS_XMAX, MTOS_YMAX, MTOS_VCHAR, MTOS_HCHAR, 
  814.        MTOS_VTIC, MTOS_HTIC, MTOS_options, MTOS_init, MTOS_reset, 
  815.        MTOS_text, null_scale, MTOS_graphics, MTOS_move, MTOS_vector, 
  816.        MTOS_linetype, MTOS_put_text, MTOS_text_angle, 
  817.        MTOS_justify_text, MTOS_point, do_arrow, set_font_null}
  818. #endif
  819.  
  820. #if defined(ATARI) || defined(MTOS)
  821.         ,{"atari", "Atari AES-Terminal",
  822.        ATARI_XMAX, ATARI_YMAX, ATARI_VCHAR, ATARI_HCHAR, 
  823.        ATARI_VTIC, ATARI_HTIC, ATARI_options, ATARI_init, ATARI_reset, 
  824.        ATARI_text, null_scale, ATARI_graphics, ATARI_move, ATARI_vector, 
  825.        ATARI_linetype, ATARI_put_text, ATARI_text_angle, 
  826.        ATARI_justify_text, ATARI_point, do_arrow, set_font_null}
  827.     ,{"vdi", "Atari VDI-Terminal",
  828.        VDI_XMAX, VDI_YMAX, VDI_VCHAR, VDI_HCHAR, 
  829.        VDI_VTIC, VDI_HTIC, VDI_options, VDI_init, VDI_reset, 
  830.        VDI_text, null_scale, VDI_graphics, VDI_move, VDI_vector, 
  831.        VDI_linetype, VDI_put_text, VDI_text_angle, 
  832.        VDI_justify_text, VDI_point, do_arrow, set_font_null}
  833. #endif
  834.  
  835. #ifdef DUMB
  836.     ,{"dumb", "printer or glass dumb terminal",
  837.          DUMB_XMAX, DUMB_YMAX, 1, 1,
  838.          1, 1, DUMB_options, DUMB_init, DUMB_reset,
  839.          DUMB_text, null_scale, DUMB_graphics, DUMB_move, DUMB_vector,
  840.          DUMB_linetype, DUMB_put_text, null_text_angle,
  841.          null_justify_text, DUMB_point, DUMB_arrow, set_font_null}
  842. #endif
  843.  
  844. #ifdef PC
  845. #ifndef _Windows
  846.     ,{"pc", "IBM PC/Clone running DOS",
  847.        PC_XMAX, PC_YMAX, PC_VCHAR, PC_HCHAR,
  848.        PC_VTIC, PC_HTIC, options_null, PC_init, PC_reset,
  849.        PC_text, null_scale, PC_graphics, PC_move, PC_vector,
  850.        PC_linetype, PC_put_text, PC_text_angle,
  851.        null_justify_text, line_and_point, do_arrow, set_font_null}
  852.  
  853. #if 0 /* now all PC (DOS) terminals are combined -- DJL */
  854.  
  855. # ifdef __TURBOC__
  856. #ifdef ATT6300
  857.     ,{"att", "IBM PC/Clone with AT&T 6300 graphics board",
  858.        ATT_XMAX, ATT_YMAX, ATT_VCHAR, ATT_HCHAR,
  859.        ATT_VTIC, ATT_HTIC, options_null, ATT_init, ATT_reset,
  860.        ATT_text, null_scale, ATT_graphics, ATT_move, ATT_vector,
  861.        ATT_linetype, ATT_put_text, ATT_text_angle, 
  862.        ATT_justify_text, line_and_point, do_arrow, set_font_null}
  863. #endif
  864.  
  865.     ,{"egalib", "IBM PC/Clone with EGA graphics board",
  866.        EGALIB_XMAX, EGALIB_YMAX, EGALIB_VCHAR, EGALIB_HCHAR,
  867.        EGALIB_VTIC, EGALIB_HTIC, options_null, EGALIB_init, EGALIB_reset,
  868.        EGALIB_text, null_scale, EGALIB_graphics, EGALIB_move, EGALIB_vector,
  869.        EGALIB_linetype, EGALIB_put_text, EGALIB_text_angle, 
  870.        EGALIB_justify_text, do_point, do_arrow, set_font_null}
  871.  
  872.     ,{"hercules", "IBM PC/Clone with Hercules graphics board",
  873.        HERC_XMAX, HERC_YMAX, HERC_VCHAR, HERC_HCHAR,
  874.        HERC_VTIC, HERC_HTIC, options_null, HERC_init, HERC_reset,
  875.        HERC_text, null_scale, HERC_graphics, HERC_move, HERC_vector,
  876.        HERC_linetype, HERC_put_text, MCGA_text_angle, 
  877.        HERC_justify_text, line_and_point, do_arrow, set_font_null}
  878.  
  879.     ,{"mcga", "IBM PC/Clone with MCGA graphics board",
  880.        MCGA_XMAX, MCGA_YMAX, MCGA_VCHAR, MCGA_HCHAR,
  881.        MCGA_VTIC, MCGA_HTIC, options_null, MCGA_init, MCGA_reset,
  882.        MCGA_text, null_scale, MCGA_graphics, MCGA_move, MCGA_vector,
  883.        MCGA_linetype, MCGA_put_text, MCGA_text_angle, 
  884.        MCGA_justify_text, line_and_point, do_arrow, set_font_null}
  885.  
  886.     ,{"svga", "IBM PC/Clone with Super VGA graphics board",
  887.        SVGA_XMAX, SVGA_YMAX, SVGA_VCHAR, SVGA_HCHAR,
  888.        SVGA_VTIC, SVGA_HTIC, options_null, SVGA_init, SVGA_reset,
  889.        SVGA_text, null_scale, SVGA_graphics, SVGA_move, SVGA_vector,
  890.        SVGA_linetype, SVGA_put_text, SVGA_text_angle, 
  891.        SVGA_justify_text, do_point, do_arrow, set_font_null}
  892.  
  893.     ,{"vgalib", "IBM PC/Clone with VGA graphics board",
  894.        VGA_XMAX, VGA_YMAX, VGA_VCHAR, VGA_HCHAR,
  895.        VGA_VTIC, VGA_HTIC, options_null, VGA_init, VGA_reset,
  896.        VGA_text, null_scale, VGA_graphics, VGA_move, VGA_vector,
  897.        VGA_linetype, VGA_put_text, VGA_text_angle, 
  898.        VGA_justify_text, do_point, do_arrow, set_font_null}
  899.  
  900.     ,{"vgamono", "IBM PC/Clone with VGA Monochrome graphics board",
  901.        VGA_XMAX, VGA_YMAX, VGA_VCHAR, VGA_HCHAR,
  902.        VGA_VTIC, VGA_HTIC, options_null, VGA_init, VGA_reset,
  903.        VGA_text, null_scale, VGA_graphics, VGA_move, VGA_vector,
  904.        VGAMONO_linetype, VGA_put_text, VGA_text_angle, 
  905.        VGA_justify_text, line_and_point, do_arrow, set_font_null}
  906. #else                    /* TURBO */
  907.  
  908. #ifdef ATT6300
  909.     ,{"att", "AT&T PC/6300 graphics",
  910.        ATT_XMAX, ATT_YMAX, ATT_VCHAR, ATT_HCHAR,
  911.        ATT_VTIC, ATT_HTIC, options_null, ATT_init, ATT_reset,
  912.        ATT_text, null_scale, ATT_graphics, ATT_move, ATT_vector,
  913.        ATT_linetype, ATT_put_text, ATT_text_angle, 
  914.        null_justify_text, line_and_point, do_arrow, set_font_null}
  915. #endif
  916.  
  917.     ,{"cga", "IBM PC/Clone with CGA graphics board",
  918.        CGA_XMAX, CGA_YMAX, CGA_VCHAR, CGA_HCHAR,
  919.        CGA_VTIC, CGA_HTIC, options_null, CGA_init, CGA_reset,
  920.        CGA_text, null_scale, CGA_graphics, CGA_move, CGA_vector,
  921.        CGA_linetype, CGA_put_text, CGA_text_angle, 
  922.        null_justify_text, line_and_point, do_arrow, set_font_null}
  923.  
  924. #ifdef CORONA
  925.     ,{"corona325", "Corona graphics ???",
  926.        COR_XMAX, COR_YMAX, COR_VCHAR, COR_HCHAR,
  927.        COR_VTIC, COR_HTIC, options_null, COR_init, COR_reset,
  928.        COR_text, null_scale, COR_graphics, COR_move, COR_vector,
  929.        COR_linetype, COR_put_text, COR_text_angle, 
  930.        null_justify_text, line_and_point, do_arrow, set_font_null}
  931. #endif                    /* CORONA */
  932.  
  933.     ,{"egabios", "IBM PC/Clone with EGA graphics board (BIOS)",
  934.        EGA_XMAX, EGA_YMAX, EGA_VCHAR, EGA_HCHAR,
  935.        EGA_VTIC, EGA_HTIC, options_null, EGA_init, EGA_reset,
  936.        EGA_text, null_scale, EGA_graphics, EGA_move, EGA_vector,
  937.        EGA_linetype, EGA_put_text, EGA_text_angle, 
  938.        null_justify_text, do_point, do_arrow, set_font_null}
  939.  
  940. #ifdef EGALIB
  941.     ,{"egalib", "IBM PC/Clone with EGA graphics board (LIB)",
  942.        EGALIB_XMAX, EGALIB_YMAX, EGALIB_VCHAR, EGALIB_HCHAR,
  943.        EGALIB_VTIC, EGALIB_HTIC, options_null, EGALIB_init, EGALIB_reset,
  944.        EGALIB_text, null_scale, EGALIB_graphics, EGALIB_move, EGALIB_vector,
  945.        EGALIB_linetype, EGALIB_put_text, null_text_angle, 
  946.        null_justify_text, do_point, do_arrow, set_font_null}
  947. #endif
  948.  
  949. #ifdef HERCULES
  950.     ,{"hercules", "IBM PC/Clone with Hercules graphics board",
  951.        HERC_XMAX, HERC_YMAX, HERC_VCHAR, HERC_HCHAR,
  952.        HERC_VTIC, HERC_HTIC, options_null, HERC_init, HERC_reset,
  953.        HERC_text, null_scale, HERC_graphics, HERC_move, HERC_vector,
  954.        HERC_linetype, HERC_put_text, HERC_text_angle, 
  955.        null_justify_text, line_and_point, do_arrow, set_font_null}
  956. #endif                    /* HERCULES */
  957.  
  958.     ,{"vgabios", "IBM PC/Clone with VGA graphics board (BIOS)",
  959.        VGA_XMAX, VGA_YMAX, VGA_VCHAR, VGA_HCHAR,
  960.        VGA_VTIC, VGA_HTIC, options_null, VGA_init, VGA_reset,
  961.        VGA_text, null_scale, VGA_graphics, VGA_move, VGA_vector,
  962.        VGA_linetype, VGA_put_text, VGA_text_angle, 
  963.        null_justify_text, do_point, do_arrow, set_font_null}
  964.  
  965. #endif                    /* TURBO */
  966.  
  967. #endif               /* 0 */
  968.  
  969. #endif                    /* _Windows */
  970. #endif                    /* PC */
  971.  
  972. #ifdef __ZTC__         /* zortech C flashgraphics for 386 */
  973.     ,{"hercules", "IBM PC/Clone with Hercules graphics board",
  974.        HERC_XMAX, HERC_YMAX, HERC_VCHAR, HERC_HCHAR,
  975.        HERC_VTIC, HERC_HTIC, options_null, VGA_init, VGA_reset,
  976.        VGA_text, null_scale, HERC_graphics, VGA_move, VGA_vector,
  977.        VGA_linetype, VGA_put_text, VGA_text_angle, 
  978.        VGA_justify_text, do_point, do_arrow, set_font_null}
  979.  
  980.     ,{"egamono", "IBM PC/Clone with monochrome EGA graphics board",
  981.        EGA_XMAX, EGA_YMAX, EGA_VCHAR, EGA_HCHAR,
  982.        EGA_VTIC, EGA_HTIC, options_null, VGA_init, VGA_reset,
  983.        VGA_text, null_scale, EGAMONO_graphics, VGA_move, VGA_vector,
  984.        VGA_linetype, VGA_put_text, VGA_text_angle, 
  985.        VGA_justify_text, do_point, do_arrow, set_font_null}
  986.  
  987.     ,{"egalib", "IBM PC/Clone with color EGA graphics board",
  988.        EGA_XMAX, EGA_YMAX, EGA_VCHAR, EGA_HCHAR,
  989.        EGA_VTIC, EGA_HTIC, options_null, VGA_init, VGA_reset,
  990.        VGA_text, null_scale, EGA_graphics, VGA_move, VGA_vector,
  991.        VGA_linetype, VGA_put_text, VGA_text_angle, 
  992.        VGA_justify_text, do_point, do_arrow, set_font_null}
  993.  
  994.     ,{"vgalib", "IBM PC/Clone with VGA graphics board",
  995.        VGA_XMAX, VGA_YMAX, VGA_VCHAR, VGA_HCHAR,
  996.        VGA_VTIC, VGA_HTIC, options_null, VGA_init, VGA_reset,
  997.        VGA_text, null_scale, VGA_graphics, VGA_move, VGA_vector,
  998.        VGA_linetype, VGA_put_text, VGA_text_angle, 
  999.        VGA_justify_text, do_point, do_arrow, set_font_null}
  1000.  
  1001.     ,{"vgamono", "IBM PC/Clone with monochrome VGA graphics board",
  1002.        VGA_XMAX, VGA_YMAX, VGA_VCHAR, VGA_HCHAR,
  1003.        VGA_VTIC, VGA_HTIC, options_null, VGA_init, VGA_reset,
  1004.        VGA_text, null_scale, VGAMONO_graphics, VGA_move, VGA_vector,
  1005.        VGA_linetype, VGA_put_text, VGA_text_angle, 
  1006.        VGA_justify_text, do_point, do_arrow, set_font_null}
  1007.  
  1008.     ,{"svgalib", "IBM PC/Clone with VESA Super VGA graphics board",
  1009.        SVGA_XMAX, SVGA_YMAX, SVGA_VCHAR, SVGA_HCHAR,
  1010.        SVGA_VTIC, SVGA_HTIC, options_null, VGA_init, VGA_reset,
  1011.        VGA_text, null_scale, SVGA_graphics, VGA_move, VGA_vector,
  1012.        VGA_linetype, VGA_put_text, VGA_text_angle, 
  1013.        VGA_justify_text, do_point, do_arrow, set_font_null}
  1014.  
  1015.     ,{"ssvgalib", "IBM PC/Clone with VESA 256 color 1024 by 768 super VGA",
  1016.        SSVGA_XMAX, SSVGA_YMAX, SSVGA_VCHAR, SSVGA_HCHAR,
  1017.        SSVGA_VTIC, SSVGA_HTIC, options_null, VGA_init, VGA_reset,
  1018.        VGA_text, null_scale, SSVGA_graphics, VGA_move, VGA_vector,
  1019.        VGA_linetype, VGA_put_text, VGA_text_angle, 
  1020.        VGA_justify_text, do_point, do_arrow, set_font_null}
  1021. #endif    /* __ZTC__ */
  1022.  
  1023. #ifdef AED
  1024.     ,{"aed512", "AED 512 Terminal",
  1025.        AED5_XMAX, AED_YMAX, AED_VCHAR, AED_HCHAR,
  1026.        AED_VTIC, AED_HTIC, options_null, AED_init, AED_reset, 
  1027.        AED_text, null_scale, AED_graphics, AED_move, AED_vector, 
  1028.        AED_linetype, AED_put_text, null_text_angle, 
  1029.        null_justify_text, do_point, do_arrow, set_font_null}
  1030.     ,{"aed767", "AED 767 Terminal",
  1031.        AED_XMAX, AED_YMAX, AED_VCHAR, AED_HCHAR,
  1032.        AED_VTIC, AED_HTIC, options_null, AED_init, AED_reset, 
  1033.        AED_text, null_scale, AED_graphics, AED_move, AED_vector, 
  1034.        AED_linetype, AED_put_text, null_text_angle, 
  1035.        null_justify_text, do_point, do_arrow, set_font_null}
  1036. #endif
  1037.  
  1038. #ifdef AIFM
  1039.     ,{"aifm", "Adobe Illustrator 3.0 Format",
  1040.        AI_XMAX, AI_YMAX, AI_VCHAR, AI_HCHAR, 
  1041.        AI_VTIC, AI_HTIC, AI_options, AI_init, AI_reset, 
  1042.        AI_text, null_scale, AI_graphics, AI_move, AI_vector, 
  1043.        AI_linetype, AI_put_text, AI_text_angle, 
  1044.        AI_justify_text, do_point, do_arrow, set_font_null}
  1045. #endif
  1046.  
  1047. #ifdef APOLLO
  1048.        ,{"apollo", "Apollo Graphics Primitive Resource, rescaling of subsequent plots after window resizing",
  1049.        0, 0, 0, 0, /* APOLLO_XMAX, APOLLO_YMAX, APOLLO_VCHAR, APOLLO_HCHAR, are filled in at run-time */
  1050.        APOLLO_VTIC, APOLLO_HTIC, options_null, APOLLO_init, APOLLO_reset,
  1051.        APOLLO_text, null_scale, APOLLO_graphics, APOLLO_move, APOLLO_vector,
  1052.        APOLLO_linetype, APOLLO_put_text, APOLLO_text_angle,
  1053.        APOLLO_justify_text, line_and_point, do_arrow, set_font_null}
  1054. #endif
  1055.  
  1056. #ifdef GPR
  1057.        ,{"gpr", "Apollo Graphics Primitive Resource, fixed-size window",
  1058.        GPR_XMAX, GPR_YMAX, GPR_VCHAR, GPR_HCHAR,
  1059.        GPR_VTIC, GPR_HTIC, options_null, GPR_init, GPR_reset,
  1060.        GPR_text, null_scale, GPR_graphics, GPR_move, GPR_vector,
  1061.        GPR_linetype, GPR_put_text, GPR_text_angle,
  1062.        GPR_justify_text, line_and_point, do_arrow, set_font_null}
  1063. #endif
  1064.  
  1065. #ifdef BITGRAPH
  1066.     ,{"bitgraph", "BBN Bitgraph Terminal",
  1067.        BG_XMAX,BG_YMAX,BG_VCHAR, BG_HCHAR, 
  1068.        BG_VTIC, BG_HTIC, options_null, BG_init, BG_reset, 
  1069.        BG_text, null_scale, BG_graphics, BG_move, BG_vector,
  1070.        BG_linetype, BG_put_text, null_text_angle, 
  1071.        null_justify_text, line_and_point, do_arrow, set_font_null}
  1072. #endif
  1073.  
  1074. #ifdef COREL
  1075.     ,{"corel","EPS format for CorelDRAW",
  1076.      CORELD_XMAX, CORELD_YMAX, CORELD_VCHAR, CORELD_HCHAR,
  1077.      CORELD_VTIC, CORELD_HTIC, COREL_options, COREL_init, COREL_reset,
  1078.      COREL_text, null_scale, COREL_graphics, COREL_move, COREL_vector,
  1079.      COREL_linetype, COREL_put_text, COREL_text_angle,
  1080.      COREL_justify_text, do_point, do_arrow, set_font_null}
  1081. #endif
  1082.  
  1083. #ifdef CGI
  1084.     ,{"cgi", "SCO CGI drivers (requires CGIDISP or CGIPRNT env variable)",
  1085.        CGI_XMAX, CGI_YMAX, 0, 0, 
  1086.        CGI_VTIC, 0, options_null, CGI_init, CGI_reset, 
  1087.        CGI_text, null_scale, CGI_graphics, CGI_move, CGI_vector, 
  1088.        CGI_linetype, CGI_put_text, CGI_text_angle, 
  1089.        CGI_justify_text, CGI_point, do_arrow, set_font_null}
  1090.  
  1091.     ,{"hcgi", "SCO CGI drivers (hardcopy, requires CGIPRNT env variable)",
  1092.        CGI_XMAX, CGI_YMAX, 0, 0, 
  1093.        CGI_VTIC, 0, options_null, HCGI_init, CGI_reset, 
  1094.        CGI_text, null_scale, CGI_graphics, CGI_move, CGI_vector, 
  1095.        CGI_linetype, CGI_put_text, CGI_text_angle, 
  1096.        CGI_justify_text, CGI_point, do_arrow, set_font_null}
  1097. #endif
  1098.  
  1099. #ifdef DEBUG
  1100.     ,{"debug", "debugging driver",
  1101.        DEBUG_XMAX, DEBUG_YMAX, DEBUG_VCHAR, DEBUG_HCHAR,
  1102.        DEBUG_VTIC, DEBUG_HTIC, options_null, DEBUG_init, DEBUG_reset,
  1103.        DEBUG_text, null_scale, DEBUG_graphics, DEBUG_move, DEBUG_vector,
  1104.        DEBUG_linetype, DEBUG_put_text, null_text_angle, 
  1105.        DEBUG_justify_text, line_and_point, do_arrow, set_font_null}
  1106. #endif
  1107.  
  1108. #ifdef DJSVGA
  1109.     ,{"svga", "IBM PC/Clone with Super VGA graphics board",
  1110.        DJSVGA_XMAX, DJSVGA_YMAX, DJSVGA_VCHAR, DJSVGA_HCHAR,
  1111.        DJSVGA_VTIC, DJSVGA_HTIC, options_null, DJSVGA_init, DJSVGA_reset,
  1112.        DJSVGA_text, null_scale, DJSVGA_graphics, DJSVGA_move, DJSVGA_vector,
  1113.        DJSVGA_linetype, DJSVGA_put_text, null_text_angle, 
  1114.        null_justify_text, do_point, do_arrow, set_font_null}
  1115. #endif
  1116.  
  1117. #ifdef DXF
  1118.     ,{"dxf", "dxf-file for AutoCad (default size 120x80)",
  1119.        DXF_XMAX,DXF_YMAX,DXF_VCHAR, DXF_HCHAR,
  1120.        DXF_VTIC, DXF_HTIC, options_null,DXF_init, DXF_reset,
  1121.        DXF_text, null_scale, DXF_graphics, DXF_move, DXF_vector,
  1122.        DXF_linetype, DXF_put_text, DXF_text_angle,
  1123.        DXF_justify_text, do_point, do_arrow, set_font_null}
  1124. #endif
  1125.  
  1126. #ifdef DXY800A
  1127.     ,{"dxy800a", "Roland DXY800A plotter",
  1128.        DXY_XMAX, DXY_YMAX, DXY_VCHAR, DXY_HCHAR,
  1129.        DXY_VTIC, DXY_HTIC, options_null, DXY_init, DXY_reset,
  1130.        DXY_text, null_scale, DXY_graphics, DXY_move, DXY_vector,
  1131.        DXY_linetype, DXY_put_text, DXY_text_angle, 
  1132.        null_justify_text, do_point, do_arrow, set_font_null}
  1133. #endif
  1134.  
  1135. #ifdef EEPIC
  1136.     ,{"eepic", "EEPIC -- extended LaTeX picture environment",
  1137.        EEPIC_XMAX, EEPIC_YMAX, EEPIC_VCHAR, EEPIC_HCHAR, 
  1138.        EEPIC_VTIC, EEPIC_HTIC, options_null, EEPIC_init, EEPIC_reset, 
  1139.        EEPIC_text, null_scale, EEPIC_graphics, EEPIC_move, EEPIC_vector, 
  1140.        EEPIC_linetype, EEPIC_put_text, EEPIC_text_angle, 
  1141.        EEPIC_justify_text, EEPIC_point, EEPIC_arrow, set_font_null}
  1142. #endif
  1143.  
  1144. #ifdef EMTEX
  1145.     ,{"emtex", "LaTeX picture environment with emTeX specials",
  1146.        LATEX_XMAX, LATEX_YMAX, LATEX_VCHAR, LATEX_HCHAR, 
  1147.        LATEX_VTIC, LATEX_HTIC, LATEX_options, EMTEX_init, EMTEX_reset, 
  1148.        EMTEX_text, null_scale, LATEX_graphics, LATEX_move, LATEX_vector, 
  1149.        LATEX_linetype, LATEX_put_text, LATEX_text_angle, 
  1150.        LATEX_justify_text, LATEX_point, LATEX_arrow, set_font_null}
  1151. #endif
  1152.  
  1153. #ifdef EPS180
  1154.     ,{"epson_180dpi", "Epson LQ-style 180-dot per inch (24 pin) printers",
  1155.        EPS180XMAX, EPS180YMAX, EPSON180VCHAR, EPSON180HCHAR,
  1156.        EPSON180VTIC, EPSON180HTIC, options_null, EPSONinit, EPSONreset,
  1157.        EPS180text, null_scale, EPS180graphics, EPSONmove, EPSONvector,
  1158.        EPSONlinetype, EPSONput_text, EPSON_text_angle,
  1159.        null_justify_text, do_point, do_arrow, set_font_null}
  1160. #endif
  1161.  
  1162. #ifdef EPS60
  1163.     ,{"epson_60dpi", "Epson-style 60-dot per inch printers",
  1164.        EPS60XMAX, EPS60YMAX, EPSONVCHAR, EPSONHCHAR,
  1165.        EPSONVTIC, EPSONHTIC, options_null, EPSONinit, EPSONreset,
  1166.        EPS60text, null_scale, EPS60graphics, EPSONmove, EPSONvector,
  1167.        EPSONlinetype, EPSONput_text, EPSON_text_angle,
  1168.        null_justify_text, do_point, do_arrow, set_font_null}
  1169. #endif
  1170.  
  1171. #ifdef EPSONP
  1172.     ,{"epson_lx800", "Epson LX-800, Star NL-10, NX-1000, PROPRINTER ...",
  1173.        EPSONXMAX, EPSONYMAX, EPSONVCHAR, EPSONHCHAR, 
  1174.        EPSONVTIC, EPSONHTIC, options_null, EPSONinit, EPSONreset, 
  1175.        EPSONtext, null_scale, EPSONgraphics, EPSONmove, EPSONvector, 
  1176.        EPSONlinetype, EPSONput_text, EPSON_text_angle, 
  1177.        null_justify_text, line_and_point, do_arrow, set_font_null}
  1178. #endif
  1179.  
  1180. #ifdef EXCL
  1181.     ,{"excl", "Talaris EXCL Laser printer (also Talaris 1590 and others)",
  1182.        EXCL_XMAX,EXCL_YMAX, EXCL_VCHAR, EXCL_HCHAR, 
  1183.        EXCL_VTIC, EXCL_HTIC, options_null, EXCL_init,EXCL_reset, 
  1184.        EXCL_text, null_scale, EXCL_graphics, EXCL_move, EXCL_vector,
  1185.        EXCL_linetype,EXCL_put_text, null_text_angle, 
  1186.        null_justify_text, line_and_point, do_arrow, set_font_null}
  1187. #endif
  1188.  
  1189.  
  1190. #ifdef FIG
  1191. #include "fig.trm"
  1192. #endif
  1193.  
  1194. #ifdef GPIC
  1195.     ,{"gpic", "GPIC -- Produce graphs in groff using the gpic preprocessor",
  1196.        GPIC_XMAX, GPIC_YMAX, GPIC_VCHAR, GPIC_HCHAR, 
  1197.        GPIC_VTIC, GPIC_HTIC, GPIC_options, GPIC_init, GPIC_reset, 
  1198.        GPIC_text, GPIC_scale, GPIC_graphics, GPIC_move, GPIC_vector, 
  1199.        GPIC_linetype, GPIC_put_text, GPIC_text_angle, 
  1200.        GPIC_justify_text, line_and_point, GPIC_arrow, set_font_null}
  1201. #endif
  1202.  
  1203. #ifdef HP26
  1204.     ,{"hp2623A", "HP2623A and maybe others",
  1205.        HP26_XMAX, HP26_YMAX, HP26_VCHAR, HP26_HCHAR,
  1206.        HP26_VTIC, HP26_HTIC, options_null, HP26_init, HP26_reset,
  1207.        HP26_text, null_scale, HP26_graphics, HP26_move, HP26_vector,
  1208.        HP26_linetype, HP26_put_text, HP26_text_angle, 
  1209.        null_justify_text, HP26_line_and_point, do_arrow, set_font_null}
  1210. #endif
  1211.  
  1212. #ifdef HP2648
  1213.     ,{"hp2648", "HP2648 and HP2647",
  1214.        HP2648XMAX, HP2648YMAX, HP2648VCHAR, HP2648HCHAR, 
  1215.        HP2648VTIC, HP2648HTIC, options_null, HP2648init, HP2648reset, 
  1216.        HP2648text, null_scale, HP2648graphics, HP2648move, HP2648vector, 
  1217.        HP2648linetype, HP2648put_text, HP2648_text_angle, 
  1218.        null_justify_text, line_and_point, do_arrow, set_font_null}
  1219. #endif
  1220.  
  1221. #ifdef HP75
  1222.     ,{"hp7580B", "HP7580, and probably other HPs (4 pens)",
  1223.        HPGL_XMAX, HPGL_YMAX, HPGL_VCHAR, HPGL_HCHAR,
  1224.        HPGL_VTIC, HPGL_HTIC, options_null, HPGL_init, HPGL_reset,
  1225.        HPGL_text, null_scale, HPGL_graphics, HPGL_move, HPGL_vector,
  1226.        HP75_linetype, HPGL_put_text, HPGL_text_angle, 
  1227.        null_justify_text, do_point, do_arrow, set_font_null}
  1228. #endif
  1229.  
  1230. #ifdef HP7550
  1231.     ,{"hp7550", "HP7550, and probably newer HP plotter (8 pens)",
  1232.        HPGL_XMAX, HPGL_YMAX, HPGL_VCHAR, HPGL_HCHAR,
  1233.        HPGL_VTIC, HPGL_HTIC, options_null, HPGL_init, HPGL_reset,
  1234.        HP7550_text, null_scale, HPGL_graphics, HPGL_move, HPGL_vector,
  1235.        HP7550_linetype, HPGL_put_text, HPGL_text_angle, 
  1236.        null_justify_text, do_point, do_arrow, set_font_null}
  1237. #endif
  1238.  
  1239. #ifdef HP500C
  1240.       ,{"hp500c", "HP DeskJet 500c, [75 100 150 300] [rle tiff]",
  1241.        HP500C_75PPI_XMAX, HP500C_75PPI_YMAX, HP500C_75PPI_VCHAR,
  1242.        HP500C_75PPI_HCHAR, HP500C_75PPI_VTIC, HP500C_75PPI_HTIC, HP500Coptions,
  1243.        HP500Cinit, HP500Creset, HP500Ctext, null_scale,
  1244.        HP500Cgraphics, HP500Cmove, HP500Cvector, HP500Clinetype,
  1245.        HP500Cput_text, HP500Ctext_angle, null_justify_text, do_point,
  1246.        do_arrow, set_font_null}
  1247. #endif
  1248.  
  1249. #ifdef HPGL
  1250.     ,{"hpgl", "HP7475 and (hopefully) lots of others (6 pens)",
  1251.        HPGL_XMAX, HPGL_YMAX, HPGL_VCHAR, HPGL_HCHAR,
  1252.        HPGL_VTIC, HPGL_HTIC, options_null, HPGL_init, HPGL_reset,
  1253.        HPGL_text, null_scale, HPGL_graphics, HPGL_move, HPGL_vector,
  1254.        HPGL_linetype, HPGL_put_text, HPGL_text_angle, 
  1255.        null_justify_text, do_point, do_arrow, set_font_null}
  1256. #endif
  1257.  
  1258. #ifdef HPLJII
  1259.     ,{"hpljii", "HP Laserjet series II, [75 100 150 300]",
  1260.        HPLJII_75PPI_XMAX, HPLJII_75PPI_YMAX, HPLJII_75PPI_VCHAR,
  1261.        HPLJII_75PPI_HCHAR, HPLJII_75PPI_VTIC, HPLJII_75PPI_HTIC, HPLJIIoptions,
  1262.        HPLJIIinit, HPLJIIreset, HPLJIItext, null_scale,
  1263.        HPLJIIgraphics, HPLJIImove, HPLJIIvector, HPLJIIlinetype,
  1264.        HPLJIIput_text, HPLJIItext_angle, null_justify_text, line_and_point,
  1265.        do_arrow, set_font_null}
  1266.     ,{"hpdj", "HP DeskJet 500, [75 100 150 300]",
  1267.        HPLJII_75PPI_XMAX, HPLJII_75PPI_YMAX, HPLJII_75PPI_VCHAR,
  1268.        HPLJII_75PPI_HCHAR, HPLJII_75PPI_VTIC, HPLJII_75PPI_HTIC, HPLJIIoptions,
  1269.        HPLJIIinit, HPLJIIreset, HPDJtext, null_scale,
  1270.        HPDJgraphics, HPLJIImove, HPLJIIvector, HPLJIIlinetype,
  1271.        HPDJput_text, HPDJtext_angle, null_justify_text, line_and_point,
  1272.        do_arrow, set_font_null}
  1273. #endif
  1274.  
  1275. #ifdef HPPJ
  1276.     ,{"hppj", "HP PaintJet and HP3630 [FNT5X9 FNT9X17 FNT13X25]",
  1277.        HPPJ_XMAX, HPPJ_YMAX,
  1278.        HPPJ_9x17_VCHAR, HPPJ_9x17_HCHAR, HPPJ_9x17_VTIC, HPPJ_9x17_HTIC,
  1279.        HPPJoptions, HPPJinit, HPPJreset, HPPJtext, null_scale, HPPJgraphics,
  1280.        HPPJmove, HPPJvector, HPPJlinetype, HPPJput_text, HPPJtext_angle,
  1281.        null_justify_text, do_point, do_arrow, set_font_null}
  1282. #endif
  1283.  
  1284. #ifdef IMAGEN
  1285.     ,{"imagen", "Imagen laser printer",
  1286.        IMAGEN_XMAX, IMAGEN_YMAX, IMAGEN_VCHAR, IMAGEN_HCHAR, 
  1287.        IMAGEN_VTIC, IMAGEN_HTIC, IMAGEN_options, IMAGEN_init, IMAGEN_reset, 
  1288.        IMAGEN_text, IMAGEN_scale, IMAGEN_graphics, IMAGEN_move, 
  1289.        IMAGEN_vector, IMAGEN_linetype, IMAGEN_put_text, IMAGEN_text_angle,
  1290.        IMAGEN_justify_text, line_and_point, do_arrow, set_font_null}
  1291. #endif
  1292.  
  1293. #ifdef IRIS4D
  1294.     ,{"iris4d", "Silicon Graphics IRIS 4D Series Computer",
  1295.        IRIS4D_XMAX, IRIS4D_YMAX, IRIS4D_VCHAR, IRIS4D_HCHAR, 
  1296.        IRIS4D_VTIC, IRIS4D_HTIC, IRIS4D_options, IRIS4D_init, IRIS4D_reset, 
  1297.        IRIS4D_text, null_scale, IRIS4D_graphics, IRIS4D_move, IRIS4D_vector,
  1298.        IRIS4D_linetype, IRIS4D_put_text, null_text_angle, 
  1299.        null_justify_text, do_point, do_arrow, set_font_null}
  1300. #endif
  1301.  
  1302. #ifdef KERMIT
  1303.     ,{"kc_tek40xx", "MS-DOS Kermit Tek4010 terminal emulator - color",
  1304.        TEK40XMAX,TEK40YMAX,TEK40VCHAR, KTEK40HCHAR, 
  1305.        TEK40VTIC, TEK40HTIC, options_null, TEK40init, KTEK40reset, 
  1306.        KTEK40Ctext, null_scale, KTEK40graphics, TEK40move, TEK40vector, 
  1307.        KTEK40Clinetype, TEK40put_text, null_text_angle, 
  1308.        null_justify_text, do_point, do_arrow, set_font_null}
  1309.     ,{"km_tek40xx", "MS-DOS Kermit Tek4010 terminal emulator - monochrome",
  1310.        TEK40XMAX,TEK40YMAX,TEK40VCHAR, KTEK40HCHAR, 
  1311.        TEK40VTIC, TEK40HTIC, options_null, TEK40init, KTEK40reset, 
  1312.        TEK40text, null_scale, KTEK40graphics, TEK40move, TEK40vector, 
  1313.        KTEK40Mlinetype, TEK40put_text, null_text_angle, 
  1314.        null_justify_text, line_and_point, do_arrow, set_font_null}
  1315. #endif
  1316.  
  1317. #ifdef LATEX
  1318.     ,{"latex", "LaTeX picture environment",
  1319.        LATEX_XMAX, LATEX_YMAX, LATEX_VCHAR, LATEX_HCHAR, 
  1320.        LATEX_VTIC, LATEX_HTIC, LATEX_options, LATEX_init, LATEX_reset, 
  1321.        LATEX_text, null_scale, LATEX_graphics, LATEX_move, LATEX_vector, 
  1322.        LATEX_linetype, LATEX_put_text, LATEX_text_angle, 
  1323.        LATEX_justify_text, LATEX_point, LATEX_arrow, set_font_null}
  1324. #endif
  1325.  
  1326. #ifdef LINUX
  1327. #include "linux.trm"
  1328. #endif
  1329.  
  1330. #ifdef LN03P
  1331.      ,{"ln03", "LN03-plus laser printer in tektronix (EGM) mode",
  1332.     LN03PXMAX, LN03PYMAX, LN03PVCHAR, LN03PHCHAR,
  1333.     LN03PVTIC, LN03PHTIC, options_null, LN03Pinit, LN03Preset,
  1334.     LN03Ptext, null_scale, TEK40graphics, LN03Pmove, LN03Pvector,
  1335.     LN03Plinetype, LN03Pput_text, null_text_angle,
  1336.     null_justify_text, line_and_point, do_arrow, set_font_null}
  1337. #endif
  1338.  
  1339. #ifdef MF
  1340.     ,{"mf", "Metafont plotting standard",
  1341.        MF_XMAX, MF_YMAX, MF_VCHAR, MF_HCHAR, 
  1342.        MF_VTIC, MF_HTIC, options_null, MF_init, MF_reset, 
  1343.        MF_text, null_scale, MF_graphics, MF_move, MF_vector, 
  1344.        MF_linetype, MF_put_text, MF_text_angle, 
  1345.        MF_justify_text, line_and_point, MF_arrow, set_font_null}
  1346. #endif
  1347.  
  1348. #ifdef MGR
  1349.     ,{"mgr", "Mgr window system",
  1350.     /* dimensions nominal, replaced during MGR_graphics call */
  1351.        MGR_XMAX, MGR_YMAX, MGR_VCHAR, MGR_HCHAR, 
  1352.        MGR_VTIC, MGR_HTIC, options_null, MGR_init, MGR_reset, 
  1353.        MGR_text, null_scale, MGR_graphics, MGR_move, MGR_vector,
  1354.        MGR_linetype, MGR_put_text, null_text_angle, 
  1355.        null_justify_text, do_point, do_arrow, set_font_null}
  1356. #endif
  1357.  
  1358. #ifdef MIF
  1359.     ,{"mif", "Frame maker MIF 3.00 format",
  1360.           MIF_XMAX, MIF_YMAX, MIF_VCHAR, MIF_HCHAR, 
  1361.         MIF_VTIC, MIF_HTIC, MIF_options, MIF_init, MIF_reset, 
  1362.        MIF_text, null_scale, MIF_graphics, MIF_move, MIF_vector, 
  1363.        MIF_linetype, MIF_put_text, MIF_text_angle, 
  1364.        MIF_justify_text, MIF_point, do_arrow, set_font_null}
  1365. #endif
  1366.  
  1367. #ifdef NEC
  1368.     ,{"nec_cp6", "NEC printer CP6, Epson LQ-800 [monocrome color draft]",
  1369.        NECXMAX, NECYMAX, NECVCHAR, NECHCHAR, 
  1370.        NECVTIC, NECHTIC, NECoptions, NECinit, NECreset, 
  1371.        NECtext, null_scale, NECgraphics, NECmove, NECvector, 
  1372.        NEClinetype, NECput_text, NEC_text_angle, 
  1373.        null_justify_text, line_and_point, do_arrow, set_font_null}
  1374. #endif
  1375.  
  1376. #ifdef ONEXT
  1377.     ,{"onext", "Original next single window terminal",
  1378.        ONEXT_XMAX, ONEXT_YMAX, ONEXT_VCHAR, ONEXT_HCHAR, 
  1379.        ONEXT_VTIC, ONEXT_HTIC, ONEXT_options, ONEXT_init, ONEXT_reset, 
  1380.        ONEXT_text, null_scale, ONEXT_graphics, ONEXT_move, ONEXT_vector, 
  1381.        ONEXT_linetype, ONEXT_put_text, ONEXT_text_angle, 
  1382.        ONEXT_justify_text, ONEXT_point, do_arrow, set_font_null}
  1383. #endif /* The PostScript driver with NXImage displaying the PostScript on screen */
  1384.  
  1385. #ifdef NEXT
  1386. #include "next.trm"
  1387. #endif
  1388.  
  1389. #ifdef OKIDATA
  1390.     ,{"okidata", "OKIDATA 320/321 Standard",
  1391.        EPS60XMAX, EPS60YMAX, EPSONVCHAR, EPSONHCHAR,
  1392.        EPSONVTIC, EPSONHTIC, options_null, EPSONinit, EPSONreset,
  1393.        OKIDATAtext, null_scale, EPS60graphics, EPSONmove, EPSONvector,
  1394.        EPSONlinetype, EPSONput_text, EPSON_text_angle,
  1395.        null_justify_text, do_point, do_arrow, set_font_null}
  1396. #endif
  1397.  
  1398. #ifdef OS2PM
  1399. #include "pm.trm"
  1400. #endif
  1401.  
  1402. #ifdef PBM
  1403.     ,{"pbm", "Portable bitmap [small medium large] [monochrome gray color]",
  1404.        PBM_XMAX, PBM_YMAX, PBM_VCHAR,
  1405.        PBM_HCHAR, PBM_VTIC, PBM_HTIC, PBMoptions,
  1406.        PBMinit, PBMreset, PBMtext, null_scale,
  1407.        PBMgraphics, PBMmove, PBMvector, PBMlinetype,
  1408.        PBMput_text, PBMtext_angle, null_justify_text, PBMpoint,
  1409.        do_arrow, set_font_null}
  1410. #endif
  1411.  
  1412. #ifdef PCL
  1413.  ,{"pcl5", "HP LaserJet III [mode] [font] [point]",
  1414.    PCL_XMAX, PCL_YMAX, HPGL2_VCHAR, HPGL2_HCHAR,
  1415.    PCL_VTIC, PCL_HTIC, PCL_options, PCL_init, PCL_reset,
  1416.    PCL_text, null_scale, PCL_graphics, HPGL2_move, HPGL2_vector,
  1417.    HPGL2_linetype, HPGL2_put_text, HPGL2_text_angle,
  1418.    HPGL2_justify_text, do_point, do_arrow, set_font_null}
  1419. #endif
  1420.  
  1421. #ifdef POSTSCRIPT
  1422.  
  1423. #include "post.trm" /* post */
  1424.  
  1425. # ifdef PSLATEX
  1426. # include "pslatex.trm"
  1427. # endif
  1428.  
  1429. #ifdef PSTEX
  1430.     ,{"pstex", "Generic TeX with PostScript \\specials",
  1431.     PSTEX_PS_XMAX, PSTEX_PS_YMAX, PSTEX_VCHAR, PSTEX_HCHAR,
  1432.     PSTEX_PS_VTIC, PSTEX_PS_HTIC, PSTEX_options, PSTEX_init, PSTEX_reset,
  1433.     PSTEX_text, PSTEX_scale, PSTEX_graphics, PS_move, PS_vector,
  1434.     PS_linetype, PSTEX_put_text, PSTEX_text_angle,
  1435.     PSTEX_justify_text, PS_point, do_arrow, PS_set_font}
  1436. #endif
  1437.  
  1438. #endif    /* POSTSCRIPT */
  1439.  
  1440. #ifdef GRASS              /* GRASS (geographic info system) monitor */
  1441. #include "term/grass.trm"
  1442. #endif /* GRASS */
  1443.  
  1444. #ifdef PRESCRIBE
  1445.     ,{"prescribe", "Prescribe - for the Kyocera Laser Printer",
  1446.     PRE_XMAX, PRE_YMAX, PRE_VCHAR, PRE_HCHAR, 
  1447.     PRE_VTIC, PRE_HTIC, options_null, PRE_init, PRE_reset, 
  1448.     PRE_text, null_scale, PRE_graphics, PRE_move, PRE_vector, 
  1449.     PRE_linetype, PRE_put_text, null_text_angle, 
  1450.     PRE_justify_text, line_and_point, do_arrow, set_font_null}
  1451.     ,{"kyo", "Kyocera Laser Printer with Courier font",
  1452.     PRE_XMAX, PRE_YMAX, KYO_VCHAR, KYO_HCHAR, 
  1453.     PRE_VTIC, PRE_HTIC, options_null, KYO_init, PRE_reset, 
  1454.     PRE_text, null_scale, PRE_graphics, PRE_move, PRE_vector, 
  1455.     PRE_linetype, PRE_put_text, null_text_angle, 
  1456.     PRE_justify_text, line_and_point, do_arrow, set_font_null}
  1457. #endif /* PRESCRIBE */
  1458.  
  1459. #ifdef    PSTRICKS
  1460.     ,{"pstricks", "LaTeX picture environment with PSTricks macros",
  1461.        PSTRICKS_XMAX, PSTRICKS_YMAX, PSTRICKS_VCHAR, PSTRICKS_HCHAR, 
  1462.        PSTRICKS_VTIC, PSTRICKS_HTIC, PSTRICKS_options, PSTRICKS_init, PSTRICKS_reset, 
  1463.        PSTRICKS_text, PSTRICKS_scale, PSTRICKS_graphics, PSTRICKS_move, PSTRICKS_vector, 
  1464.        PSTRICKS_linetype, PSTRICKS_put_text, PSTRICKS_text_angle, 
  1465.        PSTRICKS_justify_text, PSTRICKS_point, PSTRICKS_arrow, set_font_null}
  1466. #endif
  1467.     
  1468. #ifdef QMS
  1469.     ,{"qms", "QMS/QUIC Laser printer (also Talaris 1200 and others)",
  1470.        QMS_XMAX,QMS_YMAX, QMS_VCHAR, QMS_HCHAR, 
  1471.        QMS_VTIC, QMS_HTIC, options_null, QMS_init,QMS_reset, 
  1472.        QMS_text, null_scale, QMS_graphics, QMS_move, QMS_vector,
  1473.        QMS_linetype,QMS_put_text, null_text_angle, 
  1474.        null_justify_text, line_and_point, do_arrow, set_font_null}
  1475. #endif
  1476.  
  1477. #ifdef REGIS
  1478. #include "regis.trm"
  1479. #endif
  1480.  
  1481. #ifdef RGIP
  1482.     ,{"rgip", "RGIP metafile (Uniplex). Option: fontsize (1-8)",
  1483.        RGIP_XMAX, RGIP_YMAX, RGIP_VCHAR, RGIP_HCHAR,
  1484.        RGIP_VTIC, RGIP_HTIC, RGIP_options, RGIP_init, RGIP_reset,
  1485.        RGIP_text, null_scale, RGIP_graphics, RGIP_move,
  1486.        RGIP_vector, RGIP_linetype, RGIP_put_text, RGIP_text_angle,
  1487.        RGIP_justify_text, RGIP_do_point, do_arrow, set_font_null}
  1488.     ,{"uniplex", "RGIP metafile (Uniplex). Option: fontsize (1-8)",
  1489.        RGIP_XMAX, RGIP_YMAX, RGIP_VCHAR, RGIP_HCHAR,
  1490.        RGIP_VTIC, RGIP_HTIC, RGIP_options, RGIP_init, RGIP_reset,
  1491.        RGIP_text, null_scale, RGIP_graphics, RGIP_move,
  1492.        RGIP_vector, RGIP_linetype, RGIP_put_text, RGIP_text_angle,
  1493.        RGIP_justify_text, RGIP_do_point, do_arrow, set_font_null}
  1494. #endif
  1495.  
  1496. #ifdef SELANAR
  1497.     ,{"selanar", "Selanar",
  1498.        TEK40XMAX, TEK40YMAX, TEK40VCHAR, TEK40HCHAR, 
  1499.        TEK40VTIC, TEK40HTIC, options_null, SEL_init, SEL_reset, 
  1500.        SEL_text, null_scale, SEL_graphics, TEK40move, TEK40vector, 
  1501.        TEK40linetype, TEK40put_text, null_text_angle, 
  1502.        null_justify_text, line_and_point, do_arrow, set_font_null}
  1503. #endif
  1504.  
  1505. #ifdef STARC
  1506.     ,{"starc", "Star Color Printer",
  1507.        STARCXMAX, STARCYMAX, STARCVCHAR, STARCHCHAR, 
  1508.        STARCVTIC, STARCHTIC, options_null, STARCinit, STARCreset, 
  1509.        STARCtext, null_scale, STARCgraphics, STARCmove, STARCvector, 
  1510.        STARClinetype, STARCput_text, STARC_text_angle, 
  1511.        null_justify_text, line_and_point, do_arrow, set_font_null}
  1512. #endif
  1513.  
  1514. #ifdef SUN
  1515.     ,{"sun", "SunView window system",
  1516.        SUN_XMAX, SUN_YMAX, SUN_VCHAR, SUN_HCHAR, 
  1517.        SUN_VTIC, SUN_HTIC, options_null, SUN_init, SUN_reset, 
  1518.        SUN_text, null_scale, SUN_graphics, SUN_move, SUN_vector,
  1519.        SUN_linetype, SUN_put_text, null_text_angle, 
  1520.        SUN_justify_text, line_and_point, do_arrow, set_font_null}
  1521. #endif
  1522.  
  1523. #ifdef VWS
  1524.     ,{"VWS", "VAX Windowing System (UIS)",
  1525.            VWS_XMAX, VWS_YMAX, VWS_VCHAR, VWS_HCHAR,
  1526.            VWS_VTIC, VWS_HTIC, options_null, VWS_init, VWS_reset,
  1527.            VWS_text, null_scale, VWS_graphics, VWS_move, VWS_vector,
  1528.            VWS_linetype, VWS_put_text, VWS_text_angle,
  1529.            VWS_justify_text, do_point, do_arrow, set_font_null}
  1530. #endif
  1531.  
  1532. #ifdef TANDY60
  1533.     ,{"tandy_60dpi", "Tandy DMP-130 series 60-dot per inch graphics",
  1534.        EPS60XMAX, EPS60YMAX, EPSONVCHAR, EPSONHCHAR,
  1535.        EPSONVTIC, EPSONHTIC, options_null, EPSONinit, EPSONreset,
  1536.        TANDY60text, null_scale, EPS60graphics, EPSONmove, EPSONvector,
  1537.        EPSONlinetype, EPSONput_text, EPSON_text_angle,
  1538.        null_justify_text, do_point, do_arrow, set_font_null}
  1539. #endif
  1540.  
  1541. #ifdef T410X
  1542.     ,{"tek410x", "Tektronix 4106, 4107, 4109 and 420X terminals",
  1543.        T410XXMAX, T410XYMAX, T410XVCHAR, T410XHCHAR, 
  1544.        T410XVTIC, T410XHTIC, options_null, T410X_init, T410X_reset, 
  1545.        T410X_text, null_scale, T410X_graphics, T410X_move, T410X_vector, 
  1546.        T410X_linetype, T410X_put_text, T410X_text_angle, 
  1547.        null_justify_text, T410X_point, do_arrow, set_font_null}
  1548. #endif
  1549.  
  1550. #ifdef TEK
  1551. #ifndef CTEK
  1552.     ,{"tek40xx", "Tektronix 4010 and others; most TEK emulators",
  1553.        TEK40XMAX, TEK40YMAX, TEK40VCHAR, TEK40HCHAR, 
  1554.        TEK40VTIC, TEK40HTIC, options_null, TEK40init, TEK40reset, 
  1555.        TEK40text, null_scale, TEK40graphics, TEK40move, TEK40vector, 
  1556.        TEK40linetype, TEK40put_text, null_text_angle, 
  1557.        null_justify_text, line_and_point, do_arrow, set_font_null}
  1558. #else
  1559.     ,{"tek40xx","Tektronix 4010 and others; most TEK emulators",
  1560.     TEK40XMAX, TEK40YMAX, TEK40VCHAR, TEK40HCHAR,
  1561.     TEK40VTIC, TEK40HTIC, options_null, TEK40init, TEK40reset,
  1562.     TEK40text, null_scale, TEK40graphics, CTEK_move, CTEK_vector, 
  1563.     CTEK_linetype, TEK40put_text, null_text_angle, 
  1564.     null_justify_text, line_and_point, do_arrow, set_font_null}
  1565. #endif
  1566. #endif
  1567.  
  1568.     
  1569. #ifdef TEXDRAW
  1570.     ,{"texdraw", "LaTeX texdraw environment",
  1571.        TEXDRAW_XMAX, TEXDRAW_YMAX, TEXDRAW_VCHAR, TEXDRAW_HCHAR,
  1572.     TEXDRAW_VTIC, TEXDRAW_HTIC, options_null, TEXDRAW_init, TEXDRAW_reset,
  1573.     TEXDRAW_text, null_scale, TEXDRAW_graphics, TEXDRAW_move, TEXDRAW_vector,
  1574.     TEXDRAW_linetype, TEXDRAW_put_text, TEXDRAW_text_angle,
  1575.     TEXDRAW_justify_text, TEXDRAW_point, TEXDRAW_arrow, set_font_null}
  1576. #endif
  1577.   
  1578. #ifdef TGIF
  1579. #include "tgif.trm"
  1580. #endif
  1581.  
  1582. #ifdef TPIC
  1583.     ,{"tpic", "TPIC -- LaTeX picture environment with tpic \\specials",
  1584.        TPIC_XMAX, TPIC_YMAX, TPIC_VCHAR, TPIC_HCHAR, 
  1585.        TPIC_VTIC, TPIC_HTIC, TPIC_options, TPIC_init, TPIC_reset, 
  1586.        TPIC_text, null_scale, TPIC_graphics, TPIC_move, TPIC_vector, 
  1587.        TPIC_linetype, TPIC_put_text, TPIC_text_angle, 
  1588.        TPIC_justify_text, TPIC_point, TPIC_arrow, set_font_null}
  1589. #endif
  1590.  
  1591. #ifdef UNIXPLOT
  1592. #ifdef GNUGRAPH
  1593.     ,{"unixplot", "GNU plot(1) format [\042fontname\042 font_size]",
  1594.        UP_XMAX, UP_YMAX, UP_VCHAR, UP_HCHAR,
  1595.        UP_VTIC, UP_HTIC, UP_options, UP_init, UP_reset,
  1596.        UP_text, null_scale, UP_graphics, UP_move, UP_vector,
  1597.        UP_linetype, UP_put_text, UP_text_angle,
  1598.        UP_justify_text, line_and_point, do_arrow, set_font_null}
  1599. #else
  1600.     ,{"unixplot", "Unix plotting standard (see plot(1))",
  1601.        UP_XMAX, UP_YMAX, UP_VCHAR, UP_HCHAR, 
  1602.        UP_VTIC, UP_HTIC, options_null, UP_init, UP_reset, 
  1603.        UP_text, null_scale, UP_graphics, UP_move, UP_vector, 
  1604.        UP_linetype, UP_put_text, null_text_angle, 
  1605.        null_justify_text, line_and_point, do_arrow, set_font_null}
  1606. #endif /* GNUGRAPH */
  1607. #endif
  1608.     
  1609. #ifdef UNIXPC
  1610.     ,{"unixpc", "AT&T 3b1 or AT&T 7300 Unix PC",
  1611.        uPC_XMAX, uPC_YMAX, uPC_VCHAR, uPC_HCHAR, 
  1612.        uPC_VTIC, uPC_HTIC, options_null, uPC_init, uPC_reset, 
  1613.        uPC_text, null_scale, uPC_graphics, uPC_move, uPC_vector,
  1614.        uPC_linetype, uPC_put_text, uPC_text_angle, 
  1615.        null_justify_text, line_and_point, do_arrow, set_font_null}
  1616. #endif
  1617.  
  1618. #if 0
  1619. #ifdef EMXVGA
  1620. #ifdef EMXVESA
  1621.     ,{"vesa", "IBM PC/Clone with VESA SVGA graphics board [vesa mode]",
  1622.        EMXVGA_XMAX, EMXVGA_YMAX, EMXVGA_VCHAR, EMXVGA_HCHAR,
  1623.        EMXVGA_VTIC, EMXVGA_HTIC, EMXVESA_options, EMXVESA_init, EMXVESA_reset,
  1624.        EMXVESA_text, null_scale, EMXVESA_graphics, EMXVGA_move, EMXVGA_vector,
  1625.        EMXVGA_linetype, EMXVGA_put_text, EMXVGA_text_angle, 
  1626.        null_justify_text, do_point, do_arrow, set_font_null}
  1627. #endif
  1628.     ,{"vgal", "IBM PC/Clone with VGA graphics board",
  1629.        EMXVGA_XMAX, EMXVGA_YMAX, EMXVGA_VCHAR, EMXVGA_HCHAR,
  1630.        EMXVGA_VTIC, EMXVGA_HTIC, options_null, EMXVGA_init, EMXVGA_reset,
  1631.        EMXVGA_text, null_scale, EMXVGA_graphics, EMXVGA_move, EMXVGA_vector,
  1632.        EMXVGA_linetype, EMXVGA_put_text, EMXVGA_text_angle, 
  1633.        null_justify_text, do_point, do_arrow, set_font_null}
  1634. #endif
  1635. #endif
  1636.  
  1637. #ifdef EMXVGA
  1638.     ,{"emxvga", "PC with SuperVGA running DOS or OS/2",
  1639.            EMXVGA_XMAX, EMXVGA_YMAX, EMXVGA_VCHAR, EMXVGA_HCHAR,
  1640.            EMXVGA_VTIC, EMXVGA_HTIC, options_null, EMXVGA_init, EMXVGA_reset,
  1641.            EMXVGA_text, null_scale, EMXVGA_graphics, EMXVGA_move,
  1642.        EMXVGA_vector, EMXVGA_linetype, EMXVGA_put_text, EMXVGA_text_angle,
  1643.            null_justify_text, do_point, do_arrow, set_font_null}
  1644. #endif
  1645.  
  1646. #ifdef V384
  1647.     ,{"vx384", "Vectrix 384 and Tandy color printer",
  1648.        V384_XMAX, V384_YMAX, V384_VCHAR, V384_HCHAR, 
  1649.        V384_VTIC, V384_HTIC, options_null, V384_init, V384_reset, 
  1650.        V384_text, null_scale, V384_graphics, V384_move, V384_vector, 
  1651.        V384_linetype, V384_put_text, null_text_angle, 
  1652.        null_justify_text, do_point, do_arrow, set_font_null}
  1653. #endif
  1654.  
  1655. #ifdef VTTEK
  1656.     ,{"vttek", "VT-like tek40xx terminal emulator",
  1657.        TEK40XMAX,TEK40YMAX,TEK40VCHAR, TEK40HCHAR,
  1658.        TEK40VTIC, TEK40HTIC, options_null, VTTEK40init, VTTEK40reset,
  1659.        TEK40text, null_scale, TEK40graphics, TEK40move, TEK40vector,
  1660.        VTTEK40linetype, VTTEK40put_text, null_text_angle,
  1661.        null_justify_text, line_and_point, do_arrow, set_font_null}
  1662. #endif
  1663.  
  1664. #ifdef _Windows
  1665.     ,{"windows", "Microsoft Windows",
  1666.        WIN_XMAX, WIN_YMAX, WIN_VCHAR, WIN_HCHAR, 
  1667.        WIN_VTIC, WIN_HTIC, WIN_options, WIN_init, WIN_reset, 
  1668.        WIN_text, null_scale, WIN_graphics, WIN_move, WIN_vector,
  1669.        WIN_linetype, WIN_put_text, WIN_text_angle, 
  1670.        WIN_justify_text, WIN_point, do_arrow, set_font_null}
  1671. #endif
  1672.  
  1673. #ifdef X11
  1674. #include "x11.trm"
  1675.    ,{"xlib", "X11 Window System (gnulib_x11 dump)",
  1676.        Xlib_XMAX, Xlib_YMAX, Xlib_VCHAR, Xlib_HCHAR, 
  1677.        Xlib_VTIC, Xlib_HTIC, options_null, Xlib_init, Xlib_reset, 
  1678.        Xlib_text, null_scale, Xlib_graphics, Xlib_move, Xlib_vector, 
  1679.        Xlib_linetype, Xlib_put_text, null_text_angle, 
  1680.        Xlib_justify_text, line_and_point, do_arrow, set_font_null}
  1681. #endif
  1682.  
  1683. #endif /* OLD_TERMINALS */
  1684.  
  1685. };
  1686.  
  1687. #define TERMCOUNT (sizeof(term_tbl)/sizeof(struct termentry))
  1688.  
  1689.  
  1690. void list_terms()
  1691. {
  1692. register int i;
  1693.  
  1694.     fprintf(stderr,"\nAvailable terminal types:\n");
  1695.     for (i = 0; i < TERMCOUNT; i++)
  1696.         fprintf(stderr,"  %15s  %s\n",
  1697.                term_tbl[i].name, term_tbl[i].description);
  1698.     (void) putc('\n',stderr);
  1699. }
  1700.  
  1701.  
  1702. /* set_term: get terminal number from name on command line */
  1703. /* will change 'term' variable if successful */
  1704. struct termentry *
  1705. set_term(c_token)
  1706. int c_token;
  1707. {
  1708.     register struct termentry *t=NULL;
  1709.     char *input_name;
  1710.  
  1711.     if (!token[c_token].is_token)
  1712.      int_error("terminal name expected",c_token);
  1713.     input_name = input_line + token[c_token].start_index;
  1714.     t = change_term(input_name, token[c_token].length);
  1715.     if (!t)
  1716.      int_error("unknown or ambiguous terminal type; type just 'set terminal' for a list",
  1717.              c_token);
  1718.  
  1719.     /* otherwise the type was changed */
  1720.  
  1721.     return(t);
  1722. }
  1723.  
  1724. /* change_term: get terminal number from name and set terminal type */
  1725. /* returns -1 if unknown, -2 if ambiguous, >=0 is terminal number */
  1726. struct termentry *
  1727. change_term(name, length)
  1728.     char *name;
  1729.     int length;
  1730. {
  1731.     int i;
  1732.     struct termentry *t=NULL;
  1733.  
  1734.     for (i = 0; i < TERMCOUNT; i++) {
  1735.        if (!strncmp(name,term_tbl[i].name,length)) {
  1736.           if (t)
  1737.             return(NULL);    /* ambiguous */
  1738.           t = term_tbl+i;
  1739.        }
  1740.     }
  1741.  
  1742.     if (!t)            /* unknown */
  1743.      return(NULL);
  1744.  
  1745.     /* Success: set terminal type now */
  1746.  
  1747.     term = t;
  1748.     term_init = FALSE;
  1749.     name = term->name;
  1750.  
  1751.     if (term->scale != null_scale)
  1752.         fprintf(stderr, "Warning : scale interface is not null_scale - may not work with multiplot\n");
  1753.  
  1754.     /* check that optional fields are initialised to something */
  1755.     if (term->text_angle==0)
  1756.         term->text_angle = null_text_angle;
  1757.     if (term->justify_text==0)
  1758.         term->justify_text=null_justify_text;
  1759.     if (term->point==0)
  1760.         term->point = do_point;
  1761.     if (term->arrow==0)
  1762.         term->arrow = do_arrow;
  1763.     if (term->set_font==0)
  1764.         term->set_font = set_font_null;
  1765.     if (term->set_pointsize==0)
  1766.         term->set_pointsize = null_set_pointsize;
  1767.  
  1768.     /* Special handling for unixplot term type */
  1769.     if (!strncmp("unixplot",name,8)) {
  1770.        UP_redirect (2);  /* Redirect actual stdout for unixplots */
  1771.     } else if (unixplot) {
  1772.        UP_redirect (3);  /* Put stdout back together again. */
  1773.     }
  1774.  
  1775.     if (interactive)
  1776.      fprintf(stderr, "Terminal type set to '%s'\n", name);
  1777.  
  1778.     return(t);
  1779. }
  1780.  
  1781. /*
  1782.    Routine to detect what terminal is being used (or do anything else
  1783.    that would be nice).  One anticipated (or allowed for) side effect
  1784.    is that the global ``term'' may be set. 
  1785.    The environment variable GNUTERM is checked first; if that does
  1786.    not exist, then the terminal hardware is checked, if possible, 
  1787.    and finally, we can check $TERM for some kinds of terminals.
  1788.    A default can be set with -DDEFAULTTERM=myterm in the Makefile
  1789.    or #define DEFAULTTERM myterm in term.h
  1790. */
  1791. /* thanks to osupyr!alden (Dave Alden) for the original GNUTERM code */
  1792. void init_terminal()
  1793. {
  1794.     struct termentry *t;
  1795. #ifdef DEFAULTTERM
  1796.     char *term_name = DEFAULTTERM;
  1797. #else
  1798.     char *term_name = NULL;
  1799. #endif /* DEFAULTTERM */
  1800. #if (defined(__TURBOC__) && defined(MSDOS) && !defined(_Windows)) || defined(NEXT) || defined(SUN) || defined(X11)
  1801.     char *term = NULL;        /* from TERM environment var */
  1802. #endif
  1803. #ifdef X11
  1804.     char *display = NULL;
  1805. #endif
  1806.     char *gnuterm = NULL;
  1807.  
  1808.     /* GNUTERM environment variable is primary */
  1809.     gnuterm = getenv("GNUTERM");
  1810.     if (gnuterm != (char *)NULL) {
  1811.      term_name = gnuterm;
  1812.     }
  1813.     else {
  1814.        
  1815. #ifdef __ZTC__
  1816.       term_name = ztc_init();
  1817. #endif
  1818.  
  1819. #ifdef vms
  1820.        term_name = vms_init();
  1821. #endif
  1822.  
  1823. #ifdef ONEXT
  1824.     term = getenv("TERM");
  1825.     if (term_name == (char *)NULL
  1826.         && term != (char *)NULL && strcmp(term,"onext") == 0)
  1827.           term_name = "onext";
  1828. #endif /* ONeXT */
  1829.        
  1830. #ifdef SUN
  1831.        term = getenv("TERM");    /* try $TERM */
  1832.        if (term_name == (char *)NULL
  1833.           && term != (char *)NULL && strcmp(term, "sun") == 0)
  1834.         term_name = "sun";
  1835. #endif /* sun */
  1836.  
  1837. #ifdef _Windows
  1838.         term_name = "win";
  1839. #endif /* _Windows */
  1840.  
  1841. #ifdef GPR
  1842.    if (gpr_isa_pad()) term_name = "gpr";       /* find out whether stdout is a DM pad. See term/gpr.trm */
  1843. #else
  1844. #ifdef APOLLO
  1845.    if (apollo_isa_pad()) term_name = "apollo"; /* find out whether stdout is a DM pad. See term/apollo.trm */
  1846. #endif /* APOLLO */
  1847. #endif /* GPR    */
  1848.  
  1849. #ifdef X11
  1850.        term = getenv("TERM");    /* try $TERM */
  1851.        if (term_name == (char *)NULL
  1852.           && term != (char *)NULL && strcmp(term, "xterm") == 0)
  1853.         term_name = "x11";
  1854.        display = getenv("DISPLAY");
  1855.        if (term_name == (char *)NULL && display != (char *)NULL)
  1856.         term_name = "x11";
  1857.        if (X11_Display)
  1858.         term_name = "x11";
  1859. #endif /* x11 */
  1860.  
  1861. #ifdef AMIGASCREEN
  1862.        term_name = "amiga";
  1863. #endif
  1864.  
  1865. #if defined(ATARI) || defined(MTOS)
  1866.        term_name = "atari";
  1867. #endif
  1868.  
  1869. #ifdef UNIXPC
  1870.            if (iswind() == 0) {
  1871.               term_name = "unixpc";
  1872.            }
  1873. #endif /* unixpc */
  1874.  
  1875. #ifdef CGI
  1876.        if (getenv("CGIDISP") || getenv("CGIPRNT"))
  1877.          term_name = "cgi";
  1878. #endif /*CGI */
  1879.  
  1880. #if defined(MSDOS) && defined(__EMX__)
  1881. #ifdef EMXVESA
  1882.        term_name = "vesa";
  1883. #else
  1884.        term_name = "vgal";
  1885. #endif
  1886. #endif
  1887.  
  1888. #ifdef DJGPP
  1889.         term_name = "svga";
  1890. #endif
  1891.  
  1892. #ifdef GRASS
  1893.         term_name = "grass";
  1894. #endif
  1895.  
  1896. #ifdef OS2
  1897.            term_name = "pm" ;
  1898.             /* EMX compiler has getcwd that can return drive */
  1899.            PM_init() ;
  1900. #endif /*OS2 */           
  1901.  
  1902. /* set linux terminal only if LINUX_setup was successfull, if we are on X11
  1903.    LINUX_setup has failed, also if we are logged in by network */
  1904. #ifdef LINUX
  1905.        if(LINUX_graphics_allowed)
  1906.          term_name = "linux";
  1907. #endif /* LINUX */
  1908.     }
  1909.  
  1910.     /* We have a name, try to set term type */
  1911.     if (term_name != NULL && *term_name != '\0') {
  1912.        t = change_term(term_name, (int)strlen(term_name));
  1913.        if (!t)
  1914.         fprintf(stderr, "Unknown or ambiguous terminal name '%s'\n", term_name);
  1915.        else                /* successful */
  1916.         ;
  1917.     }
  1918. }
  1919.  
  1920.  
  1921. #if defined(__ZTC__)
  1922. char *
  1923. ztc_init()
  1924. {
  1925.   int g_mode;
  1926.   char *term_name = NULL;
  1927.  
  1928.     g_mode = fg_init();
  1929.  
  1930.           switch (g_mode){
  1931.             case FG_NULL      :  fprintf(stderr,"Graphics card not detected or not supported.\n");
  1932.                                  exit(1);
  1933.             case FG_HERCFULL  :  term_name = "hercules";
  1934.                                  break;
  1935.             case FG_EGAMONO   :  term_name = "egamono";
  1936.                                  break;
  1937.             case FG_EGAECD      :  term_name = "egalib";
  1938.                                  break;
  1939.             case FG_VGA11      :  term_name = "vgamono";
  1940.                                  break;
  1941.             case FG_VGA12      :  term_name = "vgalib";
  1942.                                  break;
  1943.             case FG_VESA6A      :  term_name = "svgalib";
  1944.                                  break;
  1945.             case FG_VESA5      :  term_name = "ssvgalib";
  1946.                                  break;
  1947.             }
  1948.         fg_term();
  1949.   return(term_name);
  1950. }
  1951. #endif /* __ZTC__ */
  1952.  
  1953.  
  1954. /*
  1955.     This is always defined so we don't have to have command.c know if it
  1956.     is there or not.
  1957. */
  1958. #ifndef UNIXPLOT
  1959. void UP_redirect(caller) int caller; 
  1960. {
  1961.     caller = caller;    /* to stop Turbo C complaining 
  1962.                          * about caller not being used */
  1963. }
  1964. #else
  1965. void UP_redirect (caller)
  1966. int caller;
  1967. /*
  1968.     Unixplot can't really write to outfile--it wants to write to stdout.
  1969.     This is normally ok, but the original design of gnuplot gives us
  1970.     little choice.  Originally users of unixplot had to anticipate
  1971.     their needs and redirect all I/O to a file...  Not very gnuplot-like.
  1972.  
  1973.     caller:  1 - called from SET OUTPUT "FOO.OUT"
  1974.              2 - called from SET TERM UNIXPLOT
  1975.              3 - called from SET TERM other
  1976.              4 - called from SET OUTPUT
  1977. */
  1978. {
  1979.     switch (caller) {
  1980.     case 1:
  1981.     /* Don't save, just replace stdout w/outfile (save was already done). */
  1982.         if (unixplot)
  1983.             *(stdout) = *(outfile);  /* Copy FILE structure */
  1984.     break;
  1985.     case 2:
  1986.         if (!unixplot) {
  1987.             fflush(stdout);
  1988.             save_stdout = *(stdout);
  1989.             *(stdout) = *(outfile);  /* Copy FILE structure */
  1990.             unixplot = 1;
  1991.         }
  1992.     break;
  1993.     case 3:
  1994.     /* New terminal in use--put stdout back to original. */
  1995.         /* closepl(); */  /* This is called by the term. */
  1996.         fflush(stdout);
  1997.         *(stdout) = save_stdout;  /* Copy FILE structure */
  1998.         unixplot = 0;
  1999.     break;
  2000.     case 4:
  2001.     /*  User really wants to go to normal output... */
  2002.         if (unixplot) {
  2003.             fflush(stdout);
  2004.             *(stdout) = save_stdout;  /* Copy FILE structure */
  2005.         }
  2006.     break;
  2007.     }
  2008. }
  2009. #endif
  2010.  
  2011.  
  2012. /* test terminal by drawing border and text */
  2013. /* called from command test */
  2014. void test_term()
  2015. {
  2016.     register struct termentry *t = term;
  2017.     char *str;
  2018.     int x,y, xl,yl, i;
  2019.     unsigned int xmax, ymax;
  2020.     char label[MAX_ID_LEN];
  2021.     int scaling;
  2022.     int key_entry_height;
  2023.     int p_width;
  2024.  
  2025.     if (!term_init) {
  2026.        (*t->init)();
  2027.        term_init = TRUE;
  2028.     }
  2029.     screen_ok = FALSE;
  2030.     scaling = (*t->scale)(xsize, ysize);
  2031.     xmax = (unsigned int)(t->xmax * (scaling ? 1 : xsize));
  2032.     ymax = (unsigned int)(t->ymax * (scaling ? 1 : ysize));
  2033.     (*t->graphics)();
  2034.  
  2035.     p_width = pointsize * (t->h_tic);
  2036.     key_entry_height = pointsize * (t->v_tic) * 1.25;
  2037.     if (key_entry_height < (t->v_char) )
  2038.         key_entry_height = (t->v_char);
  2039.  
  2040.     /* border linetype */
  2041.     (*t->linetype)(-2);
  2042.     (*t->move)(0,0);
  2043.     (*t->vector)(xmax-1,0);
  2044.     (*t->vector)(xmax-1,ymax-1);
  2045.     (*t->vector)(0,ymax-1);
  2046.     (*t->vector)(0,0);
  2047.     (void) (*t->justify_text)(LEFT);
  2048.     (*t->put_text)(t->h_char*5,ymax-t->v_char*3,"Terminal Test");
  2049.     /* axis linetype */
  2050.     (*t->linetype)(-1);
  2051.     (*t->move)(xmax/2,0);
  2052.     (*t->vector)(xmax/2,ymax-1);
  2053.     (*t->move)(0,ymax/2);
  2054.     (*t->vector)(xmax-1,ymax/2);
  2055.     /* test width and height of characters */
  2056.     (*t->linetype)(-2);
  2057.     (*t->move)(  xmax/2-t->h_char*10,ymax/2+t->v_char/2);
  2058.     (*t->vector)(xmax/2+t->h_char*10,ymax/2+t->v_char/2);
  2059.     (*t->vector)(xmax/2+t->h_char*10,ymax/2-t->v_char/2);
  2060.     (*t->vector)(xmax/2-t->h_char*10,ymax/2-t->v_char/2);
  2061.     (*t->vector)(xmax/2-t->h_char*10,ymax/2+t->v_char/2);
  2062.     (*t->put_text)(xmax/2-t->h_char*10,ymax/2,
  2063.         "12345678901234567890");
  2064.     /* test justification */
  2065.     (void) (*t->justify_text)(LEFT);
  2066.     (*t->put_text)(xmax/2,ymax/2+t->v_char*6,"left justified");
  2067.     str = "centre+d text";
  2068.     if ((*t->justify_text)(CENTRE))
  2069.         (*t->put_text)(xmax/2,
  2070.                 ymax/2+t->v_char*5,str);
  2071.     else
  2072.         (*t->put_text)(xmax/2-strlen(str)*t->h_char/2,
  2073.                 ymax/2+t->v_char*5,str);
  2074.     str = "right justified";
  2075.     if ((*t->justify_text)(RIGHT))
  2076.         (*t->put_text)(xmax/2,
  2077.                 ymax/2+t->v_char*4,str);
  2078.     else
  2079.         (*t->put_text)(xmax/2-strlen(str)*t->h_char,
  2080.                 ymax/2+t->v_char*4,str);
  2081.     /* test text angle */
  2082.     str = "rotated ce+ntred text";
  2083.     if ((*t->text_angle)(1)) {
  2084.         if ((*t->justify_text)(CENTRE))
  2085.             (*t->put_text)(t->v_char,
  2086.                 ymax/2,str);
  2087.         else
  2088.             (*t->put_text)(t->v_char,
  2089.                 ymax/2-strlen(str)*t->h_char/2,str);
  2090.     }
  2091.     else {
  2092.         (void) (*t->justify_text)(LEFT);
  2093.         (*t->put_text)(t->h_char*2,ymax/2-t->v_char*2,"Can't rotate text");
  2094.     }
  2095.     (void) (*t->justify_text)(LEFT);
  2096.     (void) (*t->text_angle)(0);
  2097.     /* test tic size */
  2098.     (*t->move)( (unsigned int) (xmax/2+t->h_tic*(1+ticscale)) ,0U);
  2099.     (*t->vector)( (unsigned int)(xmax/2+t->h_tic*(1+ticscale)),(unsigned int)(ticscale*t->v_tic));
  2100.     (*t->move)((unsigned int)(xmax/2),(unsigned int)(t->v_tic*(1+ticscale)));
  2101.     (*t->vector)((unsigned int)(xmax/2+ticscale*t->h_tic),(unsigned int)(t->v_tic*(1+ticscale)));
  2102.     (*t->put_text)((unsigned int)(xmax/2-10*t->h_char), (unsigned int)(t->v_tic*2+t->v_char/2),"test tics");
  2103.     /* test line and point types */
  2104.     x = xmax - t->h_char*6 - p_width;
  2105.     y = ymax - key_entry_height;
  2106.     for ( i = -2; y > key_entry_height; i++ ) {
  2107.         (*t->linetype)(i);
  2108.         /*    (void) sprintf(label,"%d",i);  Jorgen Lippert
  2109.         lippert@risoe.dk */
  2110.         (void) sprintf(label,"%d",i+1);
  2111.         if ((*t->justify_text)(RIGHT))
  2112.             (*t->put_text)(x,y,label);
  2113.         else
  2114.             (*t->put_text)(x-strlen(label)*t->h_char,y,label);
  2115.         (*t->move)(x+t->h_char,y);
  2116.         (*t->vector)(x+t->h_char*4,y);
  2117.         if ( i >= -1 )
  2118.             (*t->point)(x+t->h_char*5+p_width/2,y,i);
  2119.         y -= key_entry_height;
  2120.     }
  2121.     /* test some arrows */
  2122.     (*t->linetype)(0);
  2123.     x = xmax/4;
  2124.     y = ymax/4;
  2125.     xl = t->h_tic*5;
  2126.     yl = t->v_tic*5;
  2127.     (*t->arrow)(x,y,x+xl,y,TRUE);
  2128.     (*t->arrow)(x,y,x+xl/2,y+yl,TRUE);
  2129.     (*t->arrow)(x,y,x,y+yl,TRUE);
  2130.     (*t->arrow)(x,y,x-xl/2,y+yl,FALSE);
  2131.     (*t->arrow)(x,y,x-xl,y,TRUE);
  2132.     (*t->arrow)(x,y,x-xl,y-yl,TRUE);
  2133.     (*t->arrow)(x,y,x,y-yl,TRUE);
  2134.     (*t->arrow)(x,y,x+xl,y-yl,TRUE);
  2135.     /* and back into text mode */
  2136.     (*t->text)();
  2137. }
  2138.  
  2139.  
  2140. #if defined(MSDOS)||defined(g)||defined(MTOS)||defined(OS2)||defined(_Windows)||defined(DOS386)
  2141. /* output for some terminal types must be binary to stop non Unix computers
  2142.    changing \n to \r\n. 
  2143.    If the output is not STDOUT, the following code reopens outfile 
  2144.    with binary mode. */
  2145. void
  2146. reopen_binary()
  2147. {
  2148. char filename[MAX_ID_LEN+1];
  2149.  
  2150.     if (outfile!=stdout) {
  2151.         (void) fclose(outfile);
  2152.         (void) strcpy(filename,outstr+1);    /* remove quotes */
  2153.         filename[strlen(filename)-1] = '\0';
  2154. #ifdef _Windows
  2155.         if ( !stricmp(outstr,"'PRN'") )
  2156.             (void) strcpy(filename,win_prntmp);    /* use temp file for windows */
  2157. #endif
  2158.         if ( (outfile = fopen(filename,"wb")) == (FILE *)NULL ) {
  2159.             if ( (outfile = fopen(filename,"w")) == (FILE *)NULL ) {
  2160.                 os_error("cannot reopen file with binary type; output unknown",
  2161.                     NO_CARET);
  2162.             } 
  2163.             else {
  2164.     os_error("cannot reopen file with binary type; output reset to ascii", 
  2165.                     NO_CARET);
  2166.             }
  2167.         }
  2168. #if defined(__TURBOC__) && defined(MSDOS)
  2169. #ifndef _Windows
  2170.         if ( !stricmp(outstr,"'PRN'") )
  2171.         {
  2172.         /* Put the printer into binary mode. */
  2173.         union REGS regs;
  2174.             regs.h.ah = 0x44;    /* ioctl */
  2175.             regs.h.al = 0;        /* get device info */
  2176.             regs.x.bx = fileno(outfile);
  2177.             intdos(®s, ®s);
  2178.             regs.h.dl |= 0x20;    /* binary (no ^Z intervention) */
  2179.             regs.h.dh = 0;
  2180.             regs.h.ah = 0x44;    /* ioctl */
  2181.             regs.h.al = 1;        /* set device info */
  2182.             intdos(®s, ®s);
  2183.         }
  2184. #endif
  2185. #endif
  2186.     }
  2187. }
  2188. #endif
  2189.  
  2190. #ifdef vms
  2191. /* these are needed to modify terminal characteristics */
  2192. #include <descrip.h>
  2193. #include <iodef.h>
  2194. #include <ttdef.h>
  2195. #include <tt2def.h>
  2196. #include <dcdef.h>
  2197. #include <ssdef.h>
  2198. #include <stat.h>
  2199. #include <fab.h>
  2200. static unsigned short   chan;
  2201. static int  old_char_buf[3], cur_char_buf[3];
  2202. $DESCRIPTOR(sysoutput_desc,"SYS$OUTPUT");
  2203.  
  2204. char *vms_init()
  2205. /*
  2206.  *  Look first for decw$display (decterms do regis)
  2207.  *  Determine if we have a regis terminal
  2208.  * and save terminal characteristics
  2209. */
  2210. {
  2211.    /* Save terminal characteristics in old_char_buf and
  2212.    initialise cur_char_buf to current settings. */
  2213.    int i;
  2214.    if (getenv("DECW$DISPLAY"))
  2215.        return("x11");
  2216.    sys$assign(&sysoutput_desc,&chan,0,0);
  2217.    sys$qiow(0,chan,IO$_SENSEMODE,0,0,0,old_char_buf,12,0,0,0,0);
  2218.    for (i = 0 ; i < 3 ; ++i) cur_char_buf[i] = old_char_buf[i];
  2219.    sys$dassgn(chan);
  2220.  
  2221.    /* Test if terminal is regis */
  2222.    if ((cur_char_buf[2] & TT2$M_REGIS) == TT2$M_REGIS) return("regis");
  2223.    return(NULL);
  2224. }
  2225.  
  2226. void
  2227. vms_reset()
  2228. /* set terminal to original state */
  2229. {
  2230.    int i;
  2231.    sys$assign(&sysoutput_desc,&chan,0,0);
  2232.    sys$qiow(0,chan,IO$_SETMODE,0,0,0,old_char_buf,12,0,0,0,0);
  2233.    for (i = 0 ; i < 3 ; ++i) cur_char_buf[i] = old_char_buf[i];
  2234.    sys$dassgn(chan);
  2235. }
  2236.  
  2237. void
  2238. term_mode_tek()
  2239. /* set terminal mode to tektronix */
  2240. {
  2241.    long status;
  2242.    if (outfile != stdout) return; /* don't modify if not stdout */
  2243.    sys$assign(&sysoutput_desc,&chan,0,0);
  2244.    cur_char_buf[0] = 0x004A0000 | DC$_TERM | (TT$_TEK401X<<8);
  2245.    cur_char_buf[1] = (cur_char_buf[1] & 0x00FFFFFF) | 0x18000000;
  2246.  
  2247.    cur_char_buf[1] &= ~TT$M_CRFILL;
  2248.    cur_char_buf[1] &= ~TT$M_ESCAPE;
  2249.    cur_char_buf[1] &= ~TT$M_HALFDUP;
  2250.    cur_char_buf[1] &= ~TT$M_LFFILL;
  2251.    cur_char_buf[1] &= ~TT$M_MECHFORM;
  2252.    cur_char_buf[1] &= ~TT$M_NOBRDCST;
  2253.    cur_char_buf[1] &= ~TT$M_NOECHO;
  2254.    cur_char_buf[1] &= ~TT$M_READSYNC;
  2255.    cur_char_buf[1] &= ~TT$M_REMOTE;
  2256.    cur_char_buf[1] |= TT$M_LOWER;
  2257.    cur_char_buf[1] |= TT$M_TTSYNC;
  2258.    cur_char_buf[1] |= TT$M_WRAP;
  2259.    cur_char_buf[1] &= ~TT$M_EIGHTBIT;
  2260.    cur_char_buf[1] &= ~TT$M_MECHTAB;
  2261.    cur_char_buf[1] &= ~TT$M_SCOPE;
  2262.    cur_char_buf[1] |= TT$M_HOSTSYNC;
  2263.  
  2264.    cur_char_buf[2] &= ~TT2$M_APP_KEYPAD;
  2265.    cur_char_buf[2] &= ~TT2$M_BLOCK;
  2266.    cur_char_buf[2] &= ~TT2$M_DECCRT3;
  2267.    cur_char_buf[2] &= ~TT2$M_LOCALECHO;
  2268.    cur_char_buf[2] &= ~TT2$M_PASTHRU;
  2269.    cur_char_buf[2] &= ~TT2$M_REGIS;
  2270.    cur_char_buf[2] &= ~TT2$M_SIXEL;
  2271.    cur_char_buf[2] |= TT2$M_BRDCSTMBX;
  2272.    cur_char_buf[2] |= TT2$M_EDITING;
  2273.    cur_char_buf[2] |= TT2$M_INSERT;
  2274.    cur_char_buf[2] |= TT2$M_PRINTER;
  2275.    cur_char_buf[2] &= ~TT2$M_ANSICRT;
  2276.    cur_char_buf[2] &= ~TT2$M_AVO;
  2277.    cur_char_buf[2] &= ~TT2$M_DECCRT;
  2278.    cur_char_buf[2] &= ~TT2$M_DECCRT2;
  2279.    cur_char_buf[2] &= ~TT2$M_DRCS;
  2280.    cur_char_buf[2] &= ~TT2$M_EDIT;
  2281.    cur_char_buf[2] |= TT2$M_FALLBACK;
  2282.  
  2283.    status = sys$qiow(0,chan,IO$_SETMODE,0,0,0,cur_char_buf,12,0,0,0,0);
  2284.    if (status == SS$_BADPARAM) {
  2285.       /* terminal fallback utility not installed on system */
  2286.       cur_char_buf[2] &= ~TT2$M_FALLBACK;
  2287.       sys$qiow(0,chan,IO$_SETMODE,0,0,0,cur_char_buf,12,0,0,0,0);
  2288.    }
  2289.    else {
  2290.       if (status != SS$_NORMAL)
  2291.          lib$signal(status,0,0);
  2292.    }
  2293.    sys$dassgn(chan);
  2294. }
  2295.  
  2296. void
  2297. term_mode_native()
  2298. /* set terminal mode back to native */
  2299. {
  2300.    int i;
  2301.    if (outfile != stdout) return; /* don't modify if not stdout */
  2302.    sys$assign(&sysoutput_desc,&chan,0,0);
  2303.    sys$qiow(0,chan,IO$_SETMODE,0,0,0,old_char_buf,12,0,0,0,0);
  2304.    for (i = 0 ; i < 3 ; ++i) cur_char_buf[i] = old_char_buf[i];
  2305.    sys$dassgn(chan);
  2306. }
  2307.  
  2308. void
  2309. term_pasthru()
  2310. /* set terminal mode pasthru */
  2311. {
  2312.    if (outfile != stdout) return; /* don't modify if not stdout */
  2313.    sys$assign(&sysoutput_desc,&chan,0,0);
  2314.    cur_char_buf[2] |= TT2$M_PASTHRU;
  2315.    sys$qiow(0,chan,IO$_SETMODE,0,0,0,cur_char_buf,12,0,0,0,0);
  2316.    sys$dassgn(chan);
  2317. }
  2318.  
  2319. void
  2320. term_nopasthru()
  2321. /* set terminal mode nopasthru */
  2322. {
  2323.    if (outfile != stdout) return; /* don't modify if not stdout */
  2324.    sys$assign(&sysoutput_desc,&chan,0,0);
  2325.    cur_char_buf[2] &= ~TT2$M_PASTHRU;
  2326.    sys$qiow(0,chan,IO$_SETMODE,0,0,0,cur_char_buf,12,0,0,0,0);
  2327.    sys$dassgn(chan);
  2328. }
  2329.  
  2330. void
  2331. reopen_binary()
  2332. /* close the file outfile outfile and reopen it with binary type
  2333.    if not already done or outfile == stdout */
  2334. {
  2335.    stat_t stat_buf;
  2336.    char filename[MAX_ID_LEN+1];
  2337.    if (outfile != stdout) { /* don't modify if not stdout */
  2338.       if (!fstat(fileno(outfile),&stat_buf)) {
  2339.          if (stat_buf.st_fab_rfm != FAB$C_FIX) {
  2340.             /* modify only if not already done */
  2341.             (void) fclose(outfile);
  2342.             (void) strcpy(filename,outstr+1);   /* remove quotes */
  2343.             filename[strlen(filename)-1] = '\0';
  2344.             (void) delete(filename);
  2345.             if ((outfile = fopen(filename,"wb","rfm=fix","bls=512","mrs=512"))
  2346.                 == (FILE *)NULL ) {
  2347.                if ( (outfile = fopen(filename,"w")) == (FILE *)NULL ) {
  2348.                  os_error("cannot reopen file with binary type; output unknown",
  2349.                            NO_CARET);
  2350.                }
  2351.                else {
  2352.           os_error("cannot reopen file with binary type; output reset to ascii",
  2353.                            NO_CARET);
  2354.                }
  2355.             }
  2356.          }
  2357.       }
  2358.       else{
  2359.          os_error("cannot reopen file with binary type; output remains ascii",
  2360.                   NO_CARET);
  2361.       }
  2362.    }
  2363. }
  2364.  
  2365. void
  2366. fflush_binary()
  2367. {
  2368.    typedef short int INT16;     /* signed 16-bit integers */
  2369.    register INT16 k;            /* loop index */
  2370.    if (outfile != stdout) {
  2371.        /* Stupid VMS fflush() raises error and loses last data block
  2372.           unless it is full for a fixed-length record binary file.
  2373.           Pad it here with NULL characters. */
  2374.        for (k = (INT16)((*outfile)->_cnt); k > 0; --k)
  2375.           putc('\0',outfile);
  2376.        fflush(outfile);
  2377.    }
  2378. }
  2379. #endif
  2380.